Django Error While Trying to Create Superuser


When I tried to run this command: python createsuperuser in my Django project, it gave me a super long error which included the following:

File “”, line 22, in
File “”, line 18, in main
File “/Users/username/.local/share/virtualenvs/django-learn-csZU2bYZ/lib/python3.8/site-packages/django/core/management/”, line 364, in execute_from_command_line


ImportError: cannot import name ‘path’ from ‘django.urls’ (/Users/username/.local/share/virtualenvs/django-learn-csZU2bYZ/lib/python3.8/site-packages/django/urls/


The problem in my case was that I had the wrong version of Django installed. In order to run the python createsuperuser command you need at least Django 2.

Run this command to check the version of Django you are currently working with:

python -m django --version 

Run this command to install the latest version of Django.

pip install --upgrade django

Run the python -m django --version command again and make sure your new Django version is 2.x or above. If so, you should be able to run python createsuperuser now

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s