首页 > 解决方案 > 错误:“来自:无法读取 /var/mail/django.utils.encoding”

问题描述

python manage.py runserver在 mac 终端中遇到问题。该命令给出以下错误:ImportError: cannot import name 'python_2_unicode_compatible' from 'django.utils.encoding' (/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/django/utils/encoding.py).

尝试使用from django.utils.encoding import python_2_unicode_compatiblethen 解决该错误会导致from: can't read /var/mail/django.utils.encoding. (我确实阅读了一个可以改用的解决方案from django.utils.six import python_2_unicode_compatible,但是它给出了类似的错误from: can't read /var/mail/django.utils.six。)

一篇关于 pip 的文章提供了有关调试和解决ImportError: cannot import name 'main'的建议,因为对于升级到 pip 10 或更高版本的用户来说,这显然是一个常见错误。但是,按照调试步骤进行操作后,我找不到路径或 python 版本有任何问题(我使用的是 python 3.7)。

有人知道问题可能是什么吗?提前致谢。

注意 - 根据评论部分的建议,这里是 pip freeze 的输出:

aioredis==1.3.1
appdirs==1.4.3
asgiref==3.2.7
async-timeout==3.0.1
attrs==19.3.0
autobahn==20.3.1
Automat==20.2.0
certifi==2019.11.28
cffi==1.14.0
channels==2.4.0
channels-redis==2.4.2
constantly==15.1.0
cryptography==2.8
daphne==2.4.1
distlib==0.3.0
Django==3.0.4
django-cors-headers==3.2.1
django-polymorphic==2.1.2
django-rest-auth==0.9.5
djangorestframework==3.9.4
filelock==3.0.12
hiredis==1.0.1
hyperlink==19.0.0
idna==2.9
importlib-metadata==1.5.2
incremental==17.5.0
msgpack==0.6.2
pipenv==2018.11.26
pyasn1==0.4.8
pyasn1-modules==0.2.8
pycparser==2.20
PyHamcrest==2.0.2
pyOpenSSL==19.1.0
pytz==2019.3
service-identity==18.1.0
six==1.14.0
sqlparse==0.3.1
Twisted==20.3.0
txaio==20.3.1
virtualenv==20.0.14
virtualenv-clone==0.5.4
zipp==3.1.0
zope.interface==5.0.1

标签: pythondjangopipimporterror

解决方案


推荐阅读