To install Python 3.8 on Ubuntu version 23
Open your terminal and run these commands:
Install build dependencies
sudo apt-get update
sudo apt-get install -y build-essential libssl-dev zlib1g-dev libbz2-dev \
libreadline-dev libsqlite3-dev wget curl llvm \
libncurses5-dev libncursesw5-dev xz-utils tk-dev \
libffi-dev liblzma-dev python3-openssl git
Download and extract Python 3.8 source code
mkdir ~/python38
cd ~/python38
wget https://www.python.org/ftp/python/3.8.16/Python-3.8.16.tgz
tar -xf Python-3.8.16.tgz
cd Python-3.8.16
Configure the build
./configure --enable-optimizations
Compile the source code
make -j$(nproc)
Install Python
sudo make install
Verify the installation
python3.8 --version
To create a virtual environment specify the Python version.
Example:
python3.8 -m venv venv
How to install python 3.8.12 on /usr/bin/python? - Stack Overflow
How to Install Python 3.8 on LinuxMint
How to install Python 3.8
Why Can't I Install the Random Module?
Where can I download Python 3.8 for Ubuntu?
Does Ubuntu 20.04 include Python 3.8 by default?
Can I install a specific Python 3.8.10 version instead of 3.8.20 on Ubuntu?
Videos
To install Python 3.8 on Ubuntu version 23
Open your terminal and run these commands:
Install build dependencies
sudo apt-get update
sudo apt-get install -y build-essential libssl-dev zlib1g-dev libbz2-dev \
libreadline-dev libsqlite3-dev wget curl llvm \
libncurses5-dev libncursesw5-dev xz-utils tk-dev \
libffi-dev liblzma-dev python3-openssl git
Download and extract Python 3.8 source code
mkdir ~/python38
cd ~/python38
wget https://www.python.org/ftp/python/3.8.16/Python-3.8.16.tgz
tar -xf Python-3.8.16.tgz
cd Python-3.8.16
Configure the build
./configure --enable-optimizations
Compile the source code
make -j$(nproc)
Install Python
sudo make install
Verify the installation
python3.8 --version
To create a virtual environment specify the Python version.
Example:
python3.8 -m venv venv
Assuming you need this simply for development reasons, there's no reason to install it, but rather build it only.
Follow the steps from @GODFREY but skip the install altogether - which most probably will screw up your system.
After make -j$(nproc) you get a python binary in the directory which you can test
./python --version
# => Python 3.10.14
Now in your python project you can use virtualenv directly to use the binary
# Assuming the source is in ~/Python-3.10.14
virtualenv -p ~/Python-3.10.14/python .venv
source .venv/bin/activate
python --version
# => Python 3.10.14
That article is outdated, most likely written at a time where Python 3.8 was not yet available on the stable Ubuntu repositories.
You can install the latest Python available with just apt install python3 (3.9 at the moment).
If you really want 3.8, I suggest you take a look at the deadsnakes PPA. It contains an archive of all Python packages for Ubuntu, and also newer versions that haven't hit Ubuntu stable yet (like 3.10).
You can add this PPA and install Python 3.8 with just three commands:
add-apt-repository ppa:deadsnakes/ppa
apt update
apt install python3.8
Regarding your other two bullet points:
- Yesn't. The thing is that, by default,
/usr/binis included in yourPATHenvironment variable, which what enables you to just typepython ...instead of providing the absolute path for the binary. It is also expected by some scripts, I suppose. - You could, and you could also symlink it. The reason why it wasn't put there already is because the article used
altinstall, which prevents exactly that. It is way more preferable that you install stuff through your package manager, however.
You can do it using snap:
snap install python38
At the writing time of this article Python latest stable version 3.8 series is available to install. This article will help you to install Python 3.8 on LinuxMint operating system. You can visit here to read more about Python releases.
Step 1 – Prerequisites
Use the following command to install prerequisites for Python before installing it.
sudo apt-get install build-essential checkinstall sudo apt-get install libreadline-gplv2-dev libncursesw5-dev libssl-dev \ libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev libffi-dev zlib1g-dev
Step 2 – Download Python 3.8
Download Python from the python official site.
Step 3 – Install Python 3.8
After download extract the .tar.xz file. Then inside the Python-3.8.0 folder open terminal. Use below set of commands to install Python 3.8
./configure make make test sudo make install
All Done! This will install Python as ``python3``. Open the terminal and see yourself!
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.8command
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)
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