How to install Python 3.12 on Ubuntu - Dev Release | Python 3.12 on Ubuntu | 1
|

How to install Python 3.12 on Ubuntu – Dev Release

Python has gone through tremendous improvement in the past few years.

There was a time when Python 2.7 was alongside the Python 3 versions. Yet, versions in major release three have outgrown the 2.7. As a result, Python officially ended support for 2.7 in 2020.

Meanwhile, the subsequent versions of Python 3 have excellent improvements. The introduction of f-strings in version 3.6, data classes in 3.10, and performance boost in 3.11 are noticeable improvements.

The next exciting Python release is 3.12. The stable version will arrive in 2023. Meanwhile, you can install the development prerelease on Ubuntu OS using the steps outlined in this article.

Grab your aromatic coffee (or tea) and get ready…!

Installing Python3.12 on Ubuntu

To install Python 3.12 on Ubuntu, you can follow these steps:

1. Make sure that you have the necessary dependencies installed by running the following command:

sudo apt-get update
sudo apt-get install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev wget
Bash

2. Download the latest version of Python 3.12 from the Python downloads page at https://www.python.org/downloads/. At the time of writing, the latest version of Python 3.12 is 3.12.0a5.

3. Open a terminal and navigate to the directory where you downloaded the Python 3.12 tarball.

4. Extract the tarball by running the following command:

tar -xvf Python-3.12.0a5.tar.xz
Bash

5. Change into the extracted directory:

cd Python-3.12.0a5
Bash

6. Run the following command to configure the build:

./configure --enable-optimizations
Bash

7. Build and install Python 3.12 by running the following commands:

make -j 4
sudo make altinstall
Bash

Please note that Python’s development version is unsuitable for production use, as it may contain bugs and unfinished features. It is intended for testing and development purposes only.

If you want to install the latest stable release of Python 3.12 on Ubuntu, you can follow the same steps but download the latest stable release from the Python downloads page instead of the development version.

Test your Python 3.12 Installation

After installing Python 3.12 on Ubuntu, you can access it in a few different ways:

1. To run Python 3.12 from the command line, you can use the python3.12 command. For example, to run a Python script named myscript.py, you can use the following command:

python3.12 myscript.py
Bash

2. You can also use the python3.12 command to enter the Python interactive interpreter, which allows you to enter and execute Python commands directly. To start the interactive interpreter, run the python3.12 command with no arguments:

python3.12
Bash

3. If you have multiple versions of Python installed on your system and want to ensure that Python 3.12 is the default version, you can update the python and python3 symlinks to point to Python 3.12. For example, you can run the following commands to update the symlinks:

sudo ln -sf /usr/local/bin/python3.12 /usr/local/bin/python
sudo ln -sf /usr/local/bin/python3.12 /usr/local/bin/python3
Bash

Please note that these instructions are specific to Ubuntu, and the exact steps may vary depending on your particular distribution and installation method.

Final Thoughts

Python 3.12 is still in development, so it is unsuitable for production use. It is only intended for testing and development purposes and may contain bugs and unfinished features.

That being said, Python 3.12 is expected to include several new features and improvements over previous versions of Python. You can find more information about the proposed features for Python 3.12 in the Python Developer’s Guide.


Thanks for the read, friend. It seems you and I have lots of common interests. Say Hi to me on LinkedIn, Twitter, and Medium.

Not a Medium member yet? Please use this link to become a member because I earn a commission for referring at no extra cost for you.

Similar Posts