如何修复“模块‘平台’没有属性‘linux_distribution’"使用 Python3.8 安装新软件包时? [英] How to fix "module 'platform' has no attribute 'linux_distribution'" when installing new packages with Python3.8?
问题描述
我有 2.7 和 3.5 的 Python 版本.我想要安装一个更新版本的 Python,它是 python 3.8.我正在使用 Ubuntu 16.04,由于依赖关系,我不能只卸载 Python 3.5.所以为了运行我的脚本,我使用了 python3.8 app.py
.到目前为止没有问题.但是当我想通过 pip 安装新软件包时:
I had Python versions of 2.7 and 3.5. I wanted the install a newer version of Python which is python 3.8. I am using Ubuntu 16.04 and I can not just uninstall Python 3.5 due to the dependencies. So in order to run my scripts, I use python3.8 app.py
. No problem so far. But when I want to install new packages via pip:
python3.8 -m pip install pylint
它抛出一个错误:
AttributeError: module 'platform' has no attribute 'linux_distribution'
到目前为止,我尝试过:
So far, I tried:
sudo update-alternatives --config python3
并选择python3.8并从python3开始运行命令但没有运气.
and chose python3.8 and run command by starting with python3 but no luck.
那么:
sudo ln -sf /usr/bin/python3.5 /usr/bin/python3
我也尝试从 python3 开始运行命令,但它也不起作用.
I also tried running the command by starting with python3 but it did not work either.
如何修复它以便我可以将新包安装到新版本的 Python 中?
How can I fix it so that I can install new packages to my new version of Python?
推荐答案
看起来至少在我的 Ubuntu 16.04 上,pip 在 /usr/lib/python3/dist-packages/pip 中为所有 Python 版本共享代码>.
It looks like at least on my Ubuntu 16.04, pip is shared for all Python versions in /usr/lib/python3/dist-packages/pip
.
这是我为让它再次工作所做的:
This is what I did to get it working again:
sudo apt remove python3-pip
sudo python3.8 -m easy_install pip
您可能想使用 sudo python3.5 -m easy_install pip
再次安装 python 3.5 版本的 pip.
You might want to install the python 3.5 version of pip again with sudo python3.5 -m easy_install pip
.
这篇关于如何修复“模块‘平台’没有属性‘linux_distribution’"使用 Python3.8 安装新软件包时?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!