DEV Community

edA‑qa mort‑ora‑y
edA‑qa mort‑ora‑y

Posted on

How to install Python 3.8 on Ubuntu?

I'm having no luck getting Python 3.8 running on (K)Ubuntu 18.04. I've got the main program installed, but it's lacking pip.

I did:

sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt-get update
sudo apt-get install python3.8
Enter fullscreen mode Exit fullscreen mode

Then as tests, I also did:

sudo apt install python3.8-distutils

python3.8 -m pip install --upgrade pip setuptools wheel
Enter fullscreen mode Exit fullscreen mode

But if I try to setup a virtual env, it fails:

$ python3.8 -m venv env
Error: Command '['/src/mdl/env/bin/python3.8', '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 1.
Enter fullscreen mode Exit fullscreen mode

The module ensurepip isn't there, nor can it be installed.

$ python3.8 -m ensurepip
/usr/bin/python3.8: No module named ensurepip
Enter fullscreen mode Exit fullscreen mode

How do I install Python 3.8, along with a separate pip and package directory?


I got further with the below, added -venv and -dev to compile more packages.

sudo apt install python3.8-venv python3.8-dev
Enter fullscreen mode Exit fullscreen mode

This appeared not to work at first, but it was a 3.8 compatibility problem with a particular package, unfortunately mypy. The reason I want 3.8 is for annotations support, so this is unfortunate. They indicated a new release is coming to fix it.

Top comments (5)

Collapse
 
mortoray profile image
edA‑qa mort‑ora‑y

Digging through some closed issues I found you need to install python3.8-venv:

sudo apt-get install python3.8-venv
Enter fullscreen mode Exit fullscreen mode

Now this works:

python3.8 -m venv env
Enter fullscreen mode Exit fullscreen mode
Collapse
 
subsr97 profile image
Subramanian 😎

I'm sorry if this doesn't help. I thought of giving my two cents.

Try installing Anaconda. It's a superset of Python and comes with most commonly used packages by default. It uses a package manager called conda, which you can use for installing additional packages.
Installing Anaconda on Ubuntu 18.04

You might also find IPython really useful. It brings Jupyter notebook like features to the terminal.

Installing IPython

Collapse
 
nestedsoftware profile image
Nested Software

I think you may be missing this step: sudo apt-get install python3-pip (from vsupalov.com/developing-with-pytho...).

Collapse
 
mortoray profile image
edA‑qa mort‑ora‑y

I have that installed, and that pip doesn't work correctly with python3.8. I needed the python3.8-venv to create a virtual environment, and then I could use pip within it.

Collapse
 
weakish profile image
Jang Rush

I encountered the same problem. Finally I use pyenv to install Python 3.8 on Ubuntu 18.04.