Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
469 views
in Technique[技术] by (71.8m points)

python - How to fix "module 'platform' has no attribute 'linux_distribution'" when installing new packages with Python3.8?

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

It throws an error:

AttributeError: module 'platform' has no attribute 'linux_distribution'

So far, I tried:

sudo update-alternatives --config python3

and chose python3.8 and run command by starting with python3 but no luck.

Then:

sudo ln -sf /usr/bin/python3.5 /usr/bin/python3

I also tried running the command by starting with python3 but it did not work either.

How can I fix it so that I can install new packages to my new version of Python?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

You might want to install the python 3.5 version of pip again with sudo python3.5 -m easy_install pip.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...