Skip to main content

Command Palette

Search for a command to run...

Python 3.10 on ubuntu

Published
•2 min read•View as Markdown
💡
Currently, 3.8, 3.9 and 3.10 are getting the security updates which means these are very stable releases. This meant, that most of the software will be developed will be going with this Python version. So, In the general rule, they will be supported and choosing 3.10 is a future-proof as of now with that said, let's dive in.

Following the Python Official website download location from where you can download the python

  1. Choosing the Python Package :

To install Python 3.10.0 on Ubuntu, you should download the source code file with the .tar.xz extension. In this case, the file you should choose is:

Python-3.10.0.tar.xz - It's the source code archive for Python 3.10.0.

You can download it and then follow the typical steps to compile and install Python from source on Ubuntu. Here's a general guide for building and installing Python from source:

  1. Download Python source code:

     wget https://www.python.org/ftp/python/3.10.0/Python-3.10.0.tar.xz
    
  2. Extract the source code:

     tar -xf Python-3.10.0.tar.xz
    
  3. Navigate to the source code directory:

     cd Python-3.10.0
    
  1. Build and Install Python 3.10:

    Navigate to the Python source directory and run the following commands to build and install Python:

     cd Python-3.10.0
     ./configure --enable-optimizations
     make -j$(nproc)
     sudo make altinstall
    

    The --enable-optimizations flag is recommended to enable additional optimizations during the build process.

  2. Verify Python Installation:

    You can verify that Python 3.10 is installed correctly by running:

     python3.10 --version
    

    This should display the Python version as "Python 3.10.0."

If they are multiple Python installations, How do set the installed version to the default version

  1. First, ensure you have Python 3.10 installed on your system.

  2. Open a terminal and run the following command to configure Python alternatives:

sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.10 1

This command creates a symbolic link from /usr/bin/python to /usr/bin/python3.10 and assigns it a priority 1.

  1. Now, you can select the Python version you want to use as the default. Run:
sudo update-alternatives --config python

This command will display a list of installed Python versions, and you can choose the one you want to set as the default by entering the selection number.

After doing this, when you run python --version, it will show the version of Python 3.10. You can use the same approach to switch between different Python versions easily.

More from this blog

7F DevOps

34 posts