5

I am an Ubuntu noob and would like to ask you guys to help.

Currently I'm faced with 2 issues.

1st issue is when I'm trying mkvirtualenv --python=/usr/bin/python3.8 ENV, it threw me this error.

Error: RuntimeError: failed to query /usr/bin/python3.8 with code 1 err: 
'Traceback (most recent call last):\n  File 
"/home/yao1122/.local/lib/python2.7/site- 
packages/virtualenv/discovery/py_info.py", line 16, in <module>\n    from 
distutils.command.install import SCHEME_KEYS\nModuleNotFoundError: No module 
named \'distutils.command\'\n'

After googling from net, I decide to try install this. sudo apt-get install python3-distutils. Then it threw me this error.

Error: Unable to locate package python3-distutils

I am using ubuntu 16.04. Does anyone know what is the root cause?

Much appreciate your precious time for helping me out and THANK YOU in advance!

Ollie
  • 3,372
Byao
  • 51

3 Answers3

6

Ultimately I got it working on 16.04 using a solution I found in this thread.

Try to run the following in the terminal:

sudo apt-get install python-distutils-extra

Per the user who provided this answer, it would seem that python3-distutils ends up installed as a dependency of distutils-extra, though why this method works where other methods failed for me isn't clear.

ksharp
  • 61
0

python3-distutils and python3.8 are in the default Ubuntu 18.04 repositories, so you wouldn't get these errors in Ubuntu 18.04.


In Ubuntu 16.04 open the terminal and type:

sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt-get update
sudo apt install python3.6
cd ~/Desktop/
wget -c http://launchpadlibrarian.net/449402985/python3-lib2to3_3.6.9-1~18.04_all.deb
wget -c http://launchpadlibrarian.net/449402975/python3-distutils_3.6.9-1~18.04_all.deb
sudo apt install ./python3-lib2to3_3.6.9-1~18.04_all.deb
sudo apt install ./python3-distutils_3.6.9-1~18.04_all.deb

You might need to run update-alternatives --config python3 after the first three commands to temporarily set python3.6 as the default Python 3.X version in order to install python3-lib2to3. Changing the default Python 3 version will break a lot of applications if you don't immediately change it back to the 16.04 system default Python 3 version after you finish installing python3-lib2to3 and python3-distutils and before you close the terminal. These two packages are also compatible with Python3.8, so after you finish installing them you won't need python3.6 and the ppa:deadsnakes/ppa anymore.

If you updated with a new python (from 3.5 to 3.6), then your /usr/bin/python3 points to the new python that does not have apt_pkg. Edit /usr/bin/add-apt-repository. Change the first line of /usr/bin/add-apt-repository from #! /usr/bin/python3.6 back to #! /usr/bin/python3

karel
  • 122,292
  • 133
  • 301
  • 332
0

I think there is an easier option:

sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt-get update
sudo apt install python3.6 python3.6-dev python3.6-distutils

The deadsnakes packages provide many of the packages you might want for running python.

python3.*-venv
python3.*-2to3
python3.*-venv

https://launchpad.net/~deadsnakes/+archive/ubuntu/ppa