How do I install Python 3.8 in Lubuntu 18.04?
Solution 1
This post is community wiki so as to not claim the credit of @Kulfy's comment. This procedure worked on Ubuntu 18.04.
DON'T EVER CHANGE DEFAULT PYTHON!!! It may cause your system to break and some applications won't even run. It's far far far better to invoke python3.8 using
python3.8
command
When installing python3.8, do the following
$ sudo apt-get install python3.8 python3.8-dev python3.8-distutils python3.8-venv
For most people this will be acceptable as they will be using a virtual environment for development. Construct a virtual environment and activate it as you usually would. This will leave you in a terminal where python
resolves to python3.8
:
$ python3.8 -m venv dev3.8/
$ source dev3.8/bin/activate
(dev3.8) $ which python
...dev3.8/bin/python
(dev3.8) $ python --version
Python 3.8.0
Neglecting to install python3.8-venv
will result in an unhelpful error, that suggests you should install python-venv
which resolves to python3.6-venv
:
$ python3.8 -m venv dev3.8/ The virtual environment was not created successfully because ensurepip is not available. On Debian/Ubuntu systems, you need to install the python3-venv package using the following command. apt-get install python3-venv You may need to use sudo with that command. After installing the python3-venv package, recreate your virtual environment. Failing command: ... (trimmed for formatting)
Solution 2
Step 1: Install the latest version of python. Currently, 3.8 is the latest
sudo apt install python3.8
Step 2: Add Python 3.6 & Python 3.8 to update-alternatives
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.6.9
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.8.1
Step 3: Update Python 3 to point to Python 3.7
By default, Python 3.6 is pointed to Python 3. So, we run python3 it will execute as python3.6 but we want to execute this as python3.8
sudo update-alternatives --config python3
You should get a similar output. Now type 2 and hit enter for Python 3.
Step 4: Test the version of python
Finally test the current version of python by typing
python3 -V
Solution 3
-
Run the following commands as root or user with sudo access to update the package list and install the prerequisites:
sudo apt update sudo apt install software-properties-common
-
Add the deadsnakes PPA to your sysmtem's source list:
sudo add-apt-repository ppa:deadsnakes/ppa
-
Install Python 3.8 with following command:
sudo apt install python3.8
-
Verify the installation:
python3.8 --version
Related videos on Youtube
![Kulfy](https://i.stack.imgur.com/92eWy.jpg?s=256&g=1)
Kulfy
Born in June, 2015, I am a 5 year old pug (good boi?), whose name is derived from a dessert (Not to be confused with @dessert). I use Ubuntu 16.04, 18.04 and 20.04 with my little paws (believe me). I generally give instructions to my master to write up answers or ask questions as I dictate him (typing could be boring sometimes). For hugs and pugs ping me @ AUGR or ROLD or [email protected]. Being a pug I love Kisses. ;-) Never let them know where your food is 😉
Updated on September 18, 2022Comments
-
Kulfy almost 2 years
I downloaded Lubuntu LTS 18.04 and there is Python 3.6.9 IDLE which is built-in. But since it is very old, I want to update to 3.8. How do I do that?
-
Admin over 4 yearsThe OS is almost two years old, so the software is almost two years old. That's how it works. For newer software, use a newer release. DO NOT change the system-provided version of Python3. Doing so will break your system quite horribly.
-
Admin over 3 yearsBreak the system? What does this mean?
-
Admin about 3 yearssomething like
sudo cp python3.8 python3
might break things.
-
-
Kulfy over 4 yearsDON'T EVER CHANGE DEFAULT PYTHON!!! It may cause your system to break and some applications won't even run. It's far far far better to invoke python3.8 using
python3.8
command. -
Jeril about 4 yearsI was not able to open teminal after following the solution.
-
Chuck Batson about 4 yearsOn a fresh install of 18.04, I still received the
ensurepip
error even thoughpython3.8-venv
had been installed. Had to also installpython3.8-distutils
to resolve the virtual environment creation error. -
mhucka almost 3 yearsIn Ubuntu 18.04, I did the above to set
python3
to be 3.8, then without logging out or closing my existing terminal window, tried to start a new second terminal window. The Ubuntu wait cursor spun and nothing happened. I repeated the attempt but still no terminal started. I then reset/usr/bin/python3
back to 3.6 (by repeating theupdate-alternatives
command with a higher priority), tried to start a new terminal window, and it worked. Conclusion: as others have stated, do not change/usr/bin/python3
– leave it at 3.6. -
Snake Verde almost 3 yearsDoing the above works. However, when installing whatever happens to be in my
requirements.txt
logs this:Using legacy 'setup.py install' for <package>, since package 'wheel' is not installed.
Any reason not to installwheel
? -
Rob Hall over 2 years@SnakeVerde It's worth having wheel installed but I tend to install it in my local virtual environment. I have a small litany of commands that I execute whenever I'm modifying a virtual environment (to install packages or updates, etc). After entering into the virtual environment but before doing anything special, invoke
pip install --upgrade pip setuptools wheel
. This keeps pip from yelling about older versions and ensures that any package upgrades are using the most up-to-date versions of whatever build tools are relevant. -
Admin almost 2 years
python3.8-distutils
does not exist (anymore?) in the standard Ubuntu packages repository (packages.ubuntu.com/…). How does this affect this answer? Should installing the other listed packages still result in a complete Python 3.8 installation with working Pip?