目录
33.ImportError: cannot import name 'six' from 'django.utils'
34.ModuleNotFoundError: No module named 'django.utils.six'
36.ImportError: cannot import name 'urlresolvers' from 'django.core'
37.ImportError: cannot import name 'patterns' from 'django.conf.urls'
38.ModuleNotFoundError: No module named 'copy_reg'
39.NameError: name 'unicode' is not defined
40.AttributeError: module 'types' has no attribute 'ClassType'
41.AttributeError: module 'types' has no attribute 'InstanceType'
42.ValueError: The 'hive' package was not installed in a way that PackageLoader understands.
43.ImportError: cannot import name 'soft_unicode' from 'markupsafe'
44.AttributeError: module 'urllib' has no attribute 'quote'
46.create user_operation_log faild: module 'jwt' has no attribute 'decode'
33.ImportError: cannot import name 'six' from 'django.utils'
解决: 改为 import six
34.ModuleNotFoundError: No module named 'django.utils.six'
six.py放入django.utils下
35.ImportError: cannot import name 'cookie_date' from 'django.utils.http'
解决: python3 django3不支持cookie_date 改为 http_date
36.ImportError: cannot import name 'urlresolvers' from 'django.core'
解决: django1.3以后不支持 urlresolvers 改为 from django.urls import reverse
37.ImportError: cannot import name 'patterns' from 'django.conf.urls'
解决: 从1.10后django后patterns被移除了,已经没有这个模块了。使用 django 1.10 以后的版本需要改用 django.conf.urls.url() from django.conf.urls import patterns,include,url from django.contrib import admin from helloworld.views import hello 示例: from django.conf.urls import patterns,include,url urlpatterns = patterns('', url(r'^admin/', include(admin.site.urls)), url(r'^helloworld$', hello), ) 改为 from django.conf.urls import url,include urlpatterns = [ url(r'^admin/', include(admin.site.urls)), url(r'^helloworld$', hello), ]
38.ModuleNotFoundError: No module named 'copy_reg'
解决: copy_reg 在python3 被废除 使用 copyreg
39.NameError: name 'unicode' is not defined
解决: # python 3 doesn't have a unicode type try: unicode except: unicode = str
40.AttributeError: module 'types' has no attribute 'ClassType'
解决: /usr/local/python3/lib/python3.7/types.py 加 class _C: def _m(self): pass ClassType = type(_C)
41.AttributeError: module 'types' has no attribute 'InstanceType'
解决: /usr/local/python3/lib/python3.7/types.py 加 _x = _C() InstanceType = type(_x)
42.ValueError: The 'hive' package was not installed in a way that PackageLoader understands.
解决: jinja2原本为3.1.2版本,降低版本至2.11.2 pip3 install jinja2==2.11.2
43.ImportError: cannot import name 'soft_unicode' from 'markupsafe'
解决: soft_unicode 改为 soft_str
44.AttributeError: module 'urllib' has no attribute 'quote'
解决: from urllib.parse import quote urllib.parse 导入quote
45.django.core.management.base.SystemCheckError: SystemCheckError: System check identified some issues:
ERRORS:
?: (urls.E007) The custom handler404 view 'hive.shared.custom_404_view' does not take the correct number of arguments (request, exception).
如图新增代码解决问题
46.create user_operation_log faild: module 'jwt' has no attribute 'decode'
解决: # jwt卸载命令 pip uninstall jwt # 保险起见,将PyJWT一同卸载 pip uninstall PyJWT # 重新安装PyJWT pip install PyJWT
该系列已经完结,若有不明白的地方可以私信咨询我~