Python manage.py throws error.

Hi Experts,

      I get the following error when I run python3 manage.py collectstatic.  Please see the error below.

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/debug_toolbar/toolbar.py", line 118, in get_panel_classes
    mod = import_module(panel_module)
  File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/usr/local/lib/python3.6/dist-packages/debug_toolbar/panels/request.py", line 3, in <module>
    from django.core.urlresolvers import resolve
ModuleNotFoundError: No module named 'django.core.urlresolvers'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "manage.py", line 22, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/local/lib/python3.6/dist-packages/django/core/management/__init__.py", line 371, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python3.6/dist-packages/django/core/management/__init__.py", line 347, in execute
    django.setup()
  File "/usr/local/lib/python3.6/dist-packages/django/__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/usr/local/lib/python3.6/dist-packages/django/apps/registry.py", line 89, in populate
    app_config = AppConfig.create(entry)
  File "/usr/local/lib/python3.6/dist-packages/django/apps/config.py", line 116, in create
    mod = import_module(mod_path)
  File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/usr/local/lib/python3.6/dist-packages/debug_toolbar/apps.py", line 12, in <module>
    from debug_toolbar.middleware import DebugToolbarMiddleware
  File "/usr/local/lib/python3.6/dist-packages/debug_toolbar/middleware.py", line 17, in <module>
    from debug_toolbar.toolbar import DebugToolbar
  File "/usr/local/lib/python3.6/dist-packages/debug_toolbar/toolbar.py", line 151, in <module>
    urlpatterns = DebugToolbar.get_urls()
  File "/usr/local/lib/python3.6/dist-packages/debug_toolbar/toolbar.py", line 145, in get_urls
    for panel_class in cls.get_panel_classes():
  File "/usr/local/lib/python3.6/dist-packages/debug_toolbar/toolbar.py", line 122, in get_panel_classes
    (panel_module, e))
django.core.exceptions.ImproperlyConfigured: Error importing debug panel debug_toolbar.panels.request: "No module named 'django.core.urlresolvers'"
Error in sys.excepthook:
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 63, in apport_excepthook
    from apport.fileutils import likely_packaged, get_recent_crashes
  File "/usr/lib/python3/dist-packages/apport/__init__.py", line 5, in <module>
    from apport.report import Report
  File "/usr/lib/python3/dist-packages/apport/report.py", line 30, in <module>
    import apport.fileutils
  File "/usr/lib/python3/dist-packages/apport/fileutils.py", line 23, in <module>
    from apport.packaging_impl import impl as packaging
  File "/usr/lib/python3/dist-packages/apport/packaging_impl.py", line 23, in <module>
    import apt
  File "/usr/lib/python3/dist-packages/apt/__init__.py", line 23, in <module>
    import apt_pkg
ModuleNotFoundError: No module named 'apt_pkg'

Original exception was:
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/debug_toolbar/toolbar.py", line 118, in get_panel_classes
    mod = import_module(panel_module)
  File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/usr/local/lib/python3.6/dist-packages/debug_toolbar/panels/request.py", line 3, in <module>
    from django.core.urlresolvers import resolve
ModuleNotFoundError: No module named 'django.core.urlresolvers'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "manage.py", line 22, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/local/lib/python3.6/dist-packages/django/core/management/__init__.py", line 371, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python3.6/dist-packages/django/core/management/__init__.py", line 347, in execute
    django.setup()
  File "/usr/local/lib/python3.6/dist-packages/django/__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/usr/local/lib/python3.6/dist-packages/django/apps/registry.py", line 89, in populate
    app_config = AppConfig.create(entry)
  File "/usr/local/lib/python3.6/dist-packages/django/apps/config.py", line 116, in create
    mod = import_module(mod_path)
  File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/usr/local/lib/python3.6/dist-packages/debug_toolbar/apps.py", line 12, in <module>
    from debug_toolbar.middleware import DebugToolbarMiddleware
  File "/usr/local/lib/python3.6/dist-packages/debug_toolbar/middleware.py", line 17, in <module>
    from debug_toolbar.toolbar import DebugToolbar
  File "/usr/local/lib/python3.6/dist-packages/debug_toolbar/toolbar.py", line 151, in <module>
    urlpatterns = DebugToolbar.get_urls()
  File "/usr/local/lib/python3.6/dist-packages/debug_toolbar/toolbar.py", line 145, in get_urls
    for panel_class in cls.get_panel_classes():
  File "/usr/local/lib/python3.6/dist-packages/debug_toolbar/toolbar.py", line 122, in get_panel_classes
    (panel_module, e))
django.core.exceptions.ImproperlyConfigured: Error importing debug panel debug_toolbar.panels.request: "No module named 'django.core.urlresolvers'"

Open in new window


Please help me in resolving this I google and found change  to django.urls  django.core.urlresolvers   But I dont know where to change this.  Please help me in fixing this issue.

With many thanks,
Bharath AK
LVL 1
Bharath A.KAsked:
Who is Participating?
 
gelonidaConnect With a Mentor Commented:
This might be an issue with django versions.

Was your django project ever working?

If wes with which version?

what version of django did you install?

just check with

pip freeze | grep -i django

Open in new window

0
 
Bharath A.KAuthor Commented:
Hi Gelonida,

I get the following results on pip freeze

Django==2.0.5
django-adminplus==0.5
django-appconf==1.0.2
django-cache-url==1.3.1
django-compressor==2.1
django-debug-toolbar==1.6
django-modelcluster==3.1
django-pipeline==1.6.9
django-sass-processor==0.5.2
django-ses==0.8.1
django-storages==1.6.3
django-taggit==0.22.1
django-treebeard==4.1.0
django-webpack-loader==0.4.1
djangorestframework==3.6.3
optional-django==0.3.0

it is latest version of django.  What I have to do now?

With Many Thanks,
Bharath AK
0
 
Bharath A.KAuthor Commented:
I am able to resolve this issue.

With Many thanks,
Bharath AK
0
 
Bharath A.KAuthor Commented:
Hi Gelonida,

I had used django.core.urlresolvers in one of my views.  I changed it to django.urls it got resolved.

With Many Thanks,
Bharath AK
0
 
gelonidaCommented:
Glad you could fix it.
When upgrading Django for an existing project there's often quite some small things to change.

Fortunately the Django documentation is mostly quite helpful for such issues when looking at the release notes.
0
All Courses

From novice to tech pro — start learning today.