How to Install Python 3.12 on Ubuntu

Configurare noua (How To)

Situatie

Python is an interpreted, general-purpose, high-level programming language with a simple syntax. It is a popular programming language for web development, desktop application development, and mobile application development. Python is also a popular programming language for machine learning and artificial intelligence.

Solutie

Pasi de urmat

Install Python Using APT

APT, or Advanced Package Tool is the default package manager on Ubuntu and other Debian-based distros. You can download the Python package from the official Ubuntu repository.

  1. Open up your terminal by pressing Ctrl + Alt + T.
  2. Update your system’s repository list by entering the following command: – sudo apt update
  3. Download the latest version of Python with:   – sudo apt install python3
  4. APT will automatically find the package and install it on your computer.

Use Deadsnakes PPA to Install Python 3.12 on Ubuntu

If for some reason, you are unable to download the Python package from the official Ubuntu repositories, you can try adding the Deadsnakes PPA to your system repository list. PPAs or Personal Package Archives are repositories that are specially designed for Ubuntu users. By default, you can’t add PPAs to your system. The “software-properties-common” package provides you with an efficient way to manage and add PPAs on Ubuntu.

  1. Install the above-mentioned package on your system by typing the following command: – sudo apt install software-properties-common
  2. Add the official Deadsnakes PPA to your system’s repository list with:
    1. sudo add-apt-repository ppa:deadsnakes/ppa
  3. Update your system’s package list:
    1. sudo apt update
  4. Download the latest version of Python from the added PPA:
    1. sudo apt install python3.12
  5. Since the Deadsnakes PPA has almost every version of Python in its database, you can install older versions of Python as well. Just replace the package name with the version of Python you want to install on your computer.
    1. sudo apt install python3.3
      sudo apt install python3.8
      sudo apt install python3.10

Install Python 3 on Ubuntu From Source

You can also download and build the latest version of Python from the official Python website. Although compiling the source code might seem a bit daunting at first, it’ll become easier once you know the process.

  1. Update your system’s local repository list by running:
    1. sudo apt update
  2. Install supporting dependencies on your system with APT:
    1. sudo apt install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev wget
  3. Make a new directory to store the Python source files:
    1. mkdir ./python && cd ./python
  4. Download the Python source code from the official FTP server:

                  – wget https://www.python.org/ftp/python/3.12.0/Python-3.12.0b3.tgz

5. Extract the TGZ file that you just downloaded with:

                – tar -xvf Python-3.12.0b3.tgz

6. You need to perform tests and optimizations before installing Python. This is important as it increases the execution speed of your code by at least 10 percent:

               cd Python-3.12.0b3
               ./configure –enable-optimizations

7. Build the package using the MakeFile present in the directory:

– sudo make install

After you’ve implemented these steps, check if Python was installed properly on your computer by typing python3 –version in the terminal.

Tip solutie

Permanent

Voteaza

(2 din 5 persoane apreciaza acest articol)

Despre Autor

Leave A Comment?