from django.utils.importlib import import_module ImportError: No module named importlib

Hari Krishnan picture Hari Krishnan · Jun 1, 2017 · Viewed 8.2k times · Source

I am new to Django. I got a Django rest project. When i run it, an error shows as

from django.utils.importlib import import_module
ImportError: No module named importlib

I tried installing importlib with the command

pip install importlib

Then it shows

Requirement already satisfied: importlib in ./lib/python2.7/site-packages/gcm/utils.py"

So how coild i install importlib package?

Answer

spectras picture spectras · Jun 1, 2017

You don't. importlib is part of python since v2.7. The project you want to run seems to be an old project that still uses the compatibility module provided by old Django versions for when it supported python 2.6. It's been obsolete since Django 1.7. That means it's twofold outdated.

Replace all occurences of django.utils.importlib with importlib. But the project being clearly outdated, you will probably run into many other issues.