Blog available for sell
This blog is available for sale. Please 'contact us' if interested.
Advertise with us
Installing Python3.13 on Ubuntu 22.04

1. Go to the Python Download page. https://www.python.org/downloads/release/python-3130/

Download the Gzipped source tarball.


2. Extract the tgz file into a folder

tar -xvf Python-3.13.0.tgz


3. Before start installing the Python, install the system-level dependencies and packages

sudo apt update
sudo apt install -y build-essential libffi-dev libsqlite3-dev zlib1g-dev \
    libreadline-dev libbz2-dev liblzma-dev libncursesw5-dev libgdbm-dev \
    libssl-dev libdb-dev uuid-dev tk-dev


4. Now install the Python. Go to the extracted directory Python-3.13.0 and run these commands in order. This will take some time.

./configure --enable-optimizations --with-system-ffi --with-computed-gotos \
    --enable-loadable-sqlite-extensions --enable-shared --prefix=/usr/local


without --enable-loadable-sqlite-extensions option you might get the below error while using code related to panda/MySQL/SQLite.

ModuleNotFoundError: No module named '_sqlite3'

Continue with below commands

make
make test
sudo make install



5. Now verify the installation by invoking the python3 or python3.13 interpreter.


6. If you get the below error

./python3: error while loading shared libraries: libpython3.13.so.1.0: cannot open shared object file: No such file or directory

It means the system cannot locate the shared library (libpython3.13.so.1.0). This happens because we enabled shared libraries with --enable-shared during configure, but the system’s dynamic linker doesn't know where to find them.


Fix this error by running the below command

echo "/usr/local/lib" | sudo tee -a /etc/ld.so.conf.d/python3.13.conf
sudo ldconfig

Explanation:

  • /usr/local/lib is where libpython3.13.so.1.0 is installed.
  • ld.so.conf.d/python3.13.conf ensures the system recognizes this path.
  • ldconfig updates the dynamic linker run-time bindings.

  • Temporary Fix (Session Only)

    If you need a quick fix without modifying system files, export the library path manually:

    export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH

    Note: This change is temporary and will reset when you close the terminal. Add it to your ~/.bashrc or ~/.profile if you want it to persist. 


    7. Create a virtual environment

    virtualenv -p /usr/local/bin/python3.13 venv-name

    activate it and install the dependencies.


    1 comment on 'Installing Python3.13 On Ubuntu 22.04'
    Login to comment

    Joshua Kugler Feb. 5, 2025, 2:28 a.m.
    Is there a reason for not installing it from here? https://launchpad.net/~deadsnakes/+archive/ubuntu/ppa

    Related Articles:
    The Rising Popularity of Python
    The rising popularity of Python, why is python so popular, what is the future of Python, Is python going to be the top choice by 2025,...
    DigitalOcean Referral Badge

    © 2024-2025 Python Circle   Contact   Sponsor   Archive   Sitemap