ImportError cannot import name six from django utils path-to-project project niroj lib python3 7 site-packages django utils init py

0 votes

ecently, I upgraded the version of Django framework from 2.0.6 to 3.0 and suddenly after calling python manage.py shell command, I got this exception:

ImportError: cannot import name 'six' from 'django.utils' (/path-to-project/project/niroj/lib/python3.7/site-packages/django/utils/init.py)

Full trace:

Traceback (most recent call last):
  File "manage.py", line 13, in <module>
    execute_from_command_line(sys.argv)
  File "/path-to-project/project/niroj/lib/python3.7/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line
    utility.execute()
  File "/path-to-project/project/niroj/lib/python3.7/site-packages/django/core/management/__init__.py", line 377, in execute
    django.setup()
  File "/path-to-project/project/niroj/lib/python3.7/site-packages/django/__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/path-to-project/project/niroj/lib/python3.7/site-packages/django/apps/registry.py", line 91, in populate
    app_config = AppConfig.create(entry)
  File "/path-to-project/project/niroj/lib/python3.7/site-packages/django/apps/config.py", line 90, in create
    module = import_module(entry)
  File "/usr/lib/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/path-to-project/project/venv/lib/python3.7/site-packages/corsheaders/__init__.py", line 1, in <module>
    from .checks import check_settings  # noqa: F401
  File "/path-to-project/project/venv/lib/python3.7/site-packages/corsheaders/checks.py", line 7, in <module>
    from django.utils import six
Aug 5, 2020 in Python by kartik
• 37,520 points
6,045 views

1 answer to this question.

0 votes

Hello @kartik,

Upgrading the packages will resolve the issue because will consider is supporting Django 3.0 now.

pip install --upgrade django-cors-headers

I also upgraded djangorestframework and drf_yasg to avoid this ImportError.

Hope it helps!!
Thank You!

answered Aug 5, 2020 by Niroj
• 82,800 points

Related Questions In Python

0 votes
1 answer

How to resolve ImportError: cannot import name 'add' in python ?

There's no module called "add" in random. ...READ MORE

answered Feb 12, 2019 in Python by Mark
2,945 views
0 votes
1 answer

ImportError: cannot import name 'PILLOW_VERSION' from 'PIL' (unknown location)

Hi@akhtar, I think there is a problem in ...READ MORE

answered Apr 22, 2020 in Python by MD
• 95,300 points
3,024 views
+1 vote
1 answer

Error:Unable to import path from django.urls

Hello @kartik, You need Django version 2 pip install ...READ MORE

answered Jul 2, 2020 in Python by Niroj
• 82,800 points
4,913 views
0 votes
1 answer

ImportError: cannot import name 'render_to_response' from 'django.shortcuts'

Hello @kartik, The render_to_response shortcut was deprecated in Django 2.0, and ...READ MORE

answered Jul 2, 2020 in Python by Niroj
• 82,800 points
2,125 views
0 votes
1 answer

ImportError: cannot import name find_spec” when I start a new Django project?

Hello @kartik, find_spec isn't available in Python 3.2.3; it ...READ MORE

answered Aug 5, 2020 in Python by Niroj
• 82,800 points
832 views