Error:
1、File "/home/qwer/.local/lib/python3.6/site-packages/xadmin/sites.py", line 7, in <module>
from django.utils import six
ImportError: cannot import name 'six'
解决:
找到traceback中最后一条目录,即“????\python3.8\lib\site-packages\xadmin\sites.py”,将文件中的第7行的from django.utils import six 改成import six。
Ref: https://blog.youkuaiyun.com/ASerendipity_/article/details/103710815
2、Python.framework/Versions/3.9/lib/python3.9/site-packages/MySQLdb/__init__.py", line 24, in <module>
version_info, _mysql.version_info, _mysql.__file__
NameError: name '_mysql' is not defined
此报错主要因为Mysqldb 不兼容 python3.5 以后的版本
解决:
打开 项目目录内的 __init__.py
添加上
import pymysql
pymysql.version_info = (1, 4, 13, "final", 0)
pymysql.install_as_MySQLdb()
ref: https://blog.youkuaiyun.com/m0_47970692/article/details/114106262
3、from django.utils.encoding import python_2_unicode_compatible, smart_text
ImportError: cannot import name 'python_2_unicode_compatible'
解决:
You can fix this by changing the import wherever you get this error,
old code: from django.utils.encoding import python_2_unicode_compatible, smart_text
Updated code:
from django.utils.encoding import smart_text
from six import python_2_unicode_compatible
Go to the mentioned path and edit it, or upgrade all libraries, it should solve the issue.
Ref:https://github.com/jazzband/django-auditlog/issues/231
4、from django.forms.forms import pretty_name
ImportError: cannot import name 'pretty_name'
解决:
You can fix this by changing the import wherever you get this error,
old code: from django.forms.forms import pretty_name
Updated code: from django.forms import forms
5、No module named 'django.contrib.staticfiles.templatetags'
解决:
将from django.contrib.staticfiles.templatetags.staticfiles import static
替换成:
from django.templatetags.static import static
ref:https://www.cnblogs.com/chushujin/p/12539952.html
6、from django.db.models.fields import FieldDoesNotExist
ImportError: cannot import name 'FieldDoesNotExist'
解决:
from django.db.models.fields import FieldDoesNotExist
改成
from django.core.exceptions import FieldDoesNotExist
参考:https://stackoverflow.com/questions/63300404/makemigration-error-on-django-importerror-cannot-import-name-fielddoesnotexi
7、from import_export.admin import DEFAULT_FORMATS, SKIP_ADMIN_LOG, TMP_STORAGE_CLASS
ImportError: cannot import name 'SKIP_ADMIN_LOG'