Python——Django运行问题

1、Python3.7+Django2.2操作Mysql数据库时出现如下错误:
django.core.exceptions.ImproperlyConfigured: mysqlclient 1.3.3 or newer is required; you have 0.7.11.None

是因为MySQLclient目前只支持到python3.4,因此如果使用的更高版本的python,可以修改下面路径的文件:

C:\Users\admin\AppData\Local\Programs\Python\Python36-32\Lib\site-packages\django\db\backends\base\base.py
将if version < (1, 3, 3):
raise ImproperlyConfigured("mysqlclient 1.3.3 or newer is required; you have %s" % Database.__version__)
注释掉就可以了。
2、python创建更改文件时出现AttributeError: 'str' object has no attribute 'decode'错误

根据问题提示,意思是,属性错误:“str”对象没有属性“decode”
python3.5和Python2.7在套接字返回值解码上的区别 
python在bytes和str两种类型转换,所需要的函数依次是encode(),decode()
我得修改方法是打开报错信息最后一条路径将decode改为encode,再次运行成功生成修改文件,问题解决。

猜你喜欢

转载自www.cnblogs.com/dobiprogrammer/p/10675558.html