问题1

raise ImproperlyConfigured('mysqlclient 1.3.13 or newer is required; you have %s.' % Database.__vers

解决方法:
准备将 Django 连接到 MySQL,在命令行输入命令 python manage.py makemigrations 后报错: django.core.exceptions.ImproperlyConfigured: mysqlclient 1.3.13 or newer is required; you have 0.9.3.
由于 mysqlclient 目前不支持高版本python,出现这个错误之后可以根据错误提示找到文件位置,打开 base.py 文件,找到以下代码:

version = Database.version_info
if version < (1, 3, 13):
    raise ImproperlyConfigured('mysqlclient 1.3.13 or newer is required; you have %s.' % Database.__version__)

将 if 语句注释掉之后在执行命令就不会再报错

version = Database.version_info
# if version < (1, 3, 13):
#     raise ImproperlyConfigured('mysqlclient 1.3.13 or newer is required; you have %s.' % Database.__version__)




问题2

query = query.decode(errors='replace') AttributeError: 'str' object has no attribute 'decode'

解决方法:

File "C:\python3\lib\site-packages\django\db\backends\mysql\operations.py", line 146, in last_executed_query
    query = query.decode(errors='replace')
AttributeError: 'str' object has no attribute 'decode'

打开operations.py文件,把文件146行的decode修改为encode

if query is not None:
    query = query.encode(errors='replace')




问题3

os.getenv('PATH') nmap.nmap.PortScannerError: 'nmap program was not found in path. PATH is



linux上的解决方法
安装本地的nmap软件就可以解决
官方下载地址:https://nmap.org/

yum -y install nmap


win上的解决方法
安装本地的nmap软件就可以解决,并要在实例化nmap模块的同事带上本地的nmap路径
官方下载地址:https://nmap.org/

nm = nmap.PortScanner(nmap_search_path = ('nmap',r'C:\Program Files (x86)\Nmap\nmap.exe'))




扫描二维码,在手机上阅读!

本文由 心态很重要 创作,采用 知识共享署名 3.0,可自由转载、引用,但需署名作者且注明文章出处。

还不快抢沙发

添加新评论