概述
完整报错如下:
(python3.6) root@VPSRawstone01:~/Django2_dailyfresh-python3版本-基本完成# python manage.py makemigrations
Traceback (most recent call last):
File "manage.py", line 21, in <module>
main()
File "manage.py", line 17, in main
execute_from_command_line(sys.argv)
File "/root/.virtualenvs/python3.6/lib/python3.6/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line
utility.execute()
File "/root/.virtualenvs/python3.6/lib/python3.6/site-packages/django/core/management/__init__.py", line 377, in execute
django.setup()
File "/root/.virtualenvs/python3.6/lib/python3.6/site-packages/django/__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "/root/.virtualenvs/python3.6/lib/python3.6/site-packages/django/apps/registry.py", line 122, in populate
app_config.ready()
File "/root/.virtualenvs/python3.6/lib/python3.6/site-packages/django/contrib/admin/apps.py", line 24, in ready
self.module.autodiscover()
File "/root/.virtualenvs/python3.6/lib/python3.6/site-packages/django/contrib/admin/__init__.py", line 26, in autodiscover
autodiscover_modules('admin', register_to=site)
File "/root/.virtualenvs/python3.6/lib/python3.6/site-packages/django/utils/module_loading.py", line 47, in autodiscover_modules
import_module('%s.%s' % (app_config.name, module_to_search))
File "/root/.virtualenvs/python3.6/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 "/root/.virtualenvs/python3.6/lib/python3.6/site-packages/haystack/admin.py", line 14, in <module>
from haystack.query import SearchQuerySet
File "/root/.virtualenvs/python3.6/lib/python3.6/site-packages/haystack/query.py", line 14, in <module>
from haystack.inputs import AutoQuery, Raw
File "/root/.virtualenvs/python3.6/lib/python3.6/site-packages/haystack/inputs.py", line 8, in <module>
from django.utils.encoding import force_text, python_2_unicode_compatible
ImportError: cannot import name 'python_2_unicode_compatible'
解决方案有两个:
①给django降等级
pip install django==2.2.10
②from django.utils.encoding import python_2_unicode_compatible
改成
from six import python_2_unicode_compatible
最后
以上就是无私小刺猬为你收集整理的ImportError: cannot import name ‘python_2_unicode_compatible‘的全部内容,希望文章能够帮你解决ImportError: cannot import name ‘python_2_unicode_compatible‘所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复