python3.8执行脚本时报错AttributeError: module ‘platform’ has no attribute ‘linux_distribution’

python3.8执行脚本时报错AttributeError: module 'platform' has no attribute 'linux_distribution',如下图:

python3.8执行脚本时报错AttributeError: module 'platform' has no attribute 'linux_distribution'

报错原因是由于python3.7以后platform.linux_distribution()就被移除了,​​解决办法找到上面报错脚本pool.py​​,先安装distro,命令如下:

pip install distro

然后先编辑pool.py脚本

vim /usr/local/lib/python3.8/dist-packages/pymongo/pool.py

然后导入distro,命令如下:

import distro

python3.8执行脚本时报错AttributeError: module 'platform' has no attribute 'linux_distribution'

然后再将 platform.linux_distribution() 替换成 distro.linux_distribution() 

替换前:

python3.8执行脚本时报错AttributeError: module 'platform' has no attribute 'linux_distribution'

替换后:

python3.8执行脚本时报错AttributeError: module 'platform' has no attribute 'linux_distribution'

发表评论

相关文章