[英]from django.utils.importlib import import_module ImportError: No module named importlib
I am new to Django.我是 Django 的新手。 I got a Django rest project.
我有一个 Django 休息项目。 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我尝试使用命令安装 importlib
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?那么我如何安装 importlib 包?
You don't. 你没有。
importlib
is part of python since v2.7. 从v2.7开始,
importlib
是python的一部分。 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. 您想要运行的项目似乎是一个旧项目,它仍然使用旧Django版本提供的兼容性模块,因为它支持python 2.6。 It's been obsolete since Django 1.7.
自Django 1.7以来它已经过时了。 That means it's twofold outdated.
这意味着它已经过时了。
Replace all occurences of django.utils.importlib
with importlib
. 用
django.utils.importlib
替换django.utils.importlib
所有importlib
。 But the project being clearly outdated, you will probably run into many other issues. 但是这个项目显然过时了,你可能会遇到很多其他问题。
As suggested in the comments the importlib is part of django-appconf which is later deprecated.正如评论中所建议的,importlib 是 django-appconf 的一部分,后来被弃用。 You need to install approriate version of django-appconf.
您需要安装相应版本的 django-appconf。
pip install django-appconf==1.0.2
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.