# Install python 3.11.9 on ubuntu

**URL:** <https://discuss.python.org/t/install-python-3-11-9-on-ubuntu/51093>\
**Category:** Python Help\
**Tags:** help\
**Created:** [April 16, 2024, 4:40am UTC](https://discuss.python.org/t/install-python-3-11-9-on-ubuntu/51093 "2024-04-16T04:40:20Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![neil](https://avatars.discourse-cdn.com/v4/letter/n/839c29/32.png) [@neil](https://discuss.python.org/u/neil)\
**Post date:** [April 16, 2024, 4:40am UTC](https://discuss.python.org/t/install-python-3-11-9-on-ubuntu/51093/1 "2024-04-16T04:40:20Z")

</div>

According to this page:

> **[Python Release Python 3.11.9](https://www.python.org/downloads/release/python-3119/)**
>
> The official home of the Python Programming Language

'Python 3.11.9 is the newest major release of the Python programming language".

Can I install Python 3.11.9 in my Virtual Machine?

I have installed guest VM ubuntu-22.04.4-desktop-amd64.iso on a Windows 10 host.

In the VM, I have run the following:

> sudo apt install  
> sudo apt upgrade

this:

> python3 --version

returns:  
Python 3.10.12

When I run:

> sudo apt install python3

I receive this message:  
python3 is already at the newest version (3.10.6-1~22.04)

When I run:

> sudo apt install python3.11.9

I receive this message:  
Unable to locate package3.11.9

I am thinking my Ubuntu installation is limiting the packages to which I have access, although I don’t really have any idea.

Can I install Python 3.11.9 in my VM?

TIA.

---

<div class="post-metadata">

**Author:** ![neil](https://avatars.discourse-cdn.com/v4/letter/n/839c29/32.png) [@neil](https://discuss.python.org/u/neil)\
**Post date:** [April 16, 2024, 5:10am UTC](https://discuss.python.org/t/install-python-3-11-9-on-ubuntu/51093/2 "2024-04-16T05:10:36Z")

</div>

After consulting [gemini.google.com](http://gemini.google.com), I ran this:

> sudo add-apt-repository ppa:deadsnakes/ppa  
> sudo apt update  
> sudo apt install python3.11

I received message:  
python3.11 is already the latest version (3.11.9-1+jammy1)

however:

> python3 --version  
> returns:  
> Python 3.10.12

---

<div class="post-metadata">

**Author:** ![kknechtel](https://avatars.discourse-cdn.com/v4/letter/k/e47c2d/32.png) [@kknechtel](https://discuss.python.org/u/kknechtel)\
**Post date:** [April 16, 2024, 5:27am UTC](https://discuss.python.org/t/install-python-3-11-9-on-ubuntu/51093/3 "2024-04-16T05:27:07Z")

</div>

> [@neil](#):
>
> I am thinking my Ubuntu installation is limiting the packages to which I have access, although I don’t really have any idea.

You have understood this correctly. It is not an issue with Python, but with your Linux distribution (I use Mint, so I am affected by the same). In general, _every_ distro can be expected to have this issue with _every package offered_: only specific versions are available in the package repository, because those are the ones that the distro maintainers have pre-built for you.

If you want a different version of a library or application then you will have to use methods that are specific to that library or application, as documented by its author - and you no longer have the distro maintainer’s assurances about quality, security etc. (This is still much more secure than the Windows world, in which you are basically always on your own and at the mercy of the author to pre-build something for you, without any opportunity to review the source code.)

In the case of Python, the standard way to install on Linux is to build from source. While there are PPAs (third-party providers of pre-built application packages) that may carry Python, such as the “deadsnakes” PPA, the Python dev team has put a lot of effort into producing something that builds smoothly on the vast majority of Linux systems.

The basic guidance on installation is here:

> **[2. Using Python on Unix platforms](https://docs.python.org/3/using/unix.html)**
>
> Getting and installing the latest version of Python: On Linux: Python comes preinstalled on most Linux distributions, and is available as a package on all others. However there are certain features...

However, I strongly recommend also reading the setup instructions from the Python developer’s guide, since I find they explain the actual build process much better (and point out a couple of non-obvious, useful command-line options):

> **[Setup and building](https://devguide.python.org/getting-started/setup-building/index.html)**
>
> These instructions cover how to get a working copy of the source code and a compiled version of the CPython interpreter (CPython is the version of Python available from https://www.python.org/). It...

On Ubuntu, the overall process typically looks something like:

```python
$ # only the first time that you build Python from source:
$ # ensure that the system has the appropriate dependencies installed
$ # minimal dependencies:
$ sudo apt-get build-dep python3
$ sudo apt-get install pkg-config
$ # full optional dependencies:
$ sudo apt-get install build-essential gdb lcov pkg-config \
      libbz2-dev libffi-dev libgdbm-dev libgdbm-compat-dev liblzma-dev \
      libncurses5-dev libreadline6-dev libsqlite3-dev libssl-dev \
      lzma lzma-dev tk-dev uuid-dev zlib1g-dev
$ # Next, the actual building - assuming we have cd'd
$ # into the folder for an unzipped source tarball:
$ ./configure
$ # replace the 4 here with the number of cores your processor has
$ # with some versions of make, just "-j" will work
$ make -j4 -s
$ # install in a way that won't interfere with the system Python
$ make altinstall

```

---

<div class="post-metadata">

**Author:** ![neil](https://avatars.discourse-cdn.com/v4/letter/n/839c29/32.png) [@neil](https://discuss.python.org/u/neil)\
**Post date:** [April 16, 2024, 6:07am UTC](https://discuss.python.org/t/install-python-3-11-9-on-ubuntu/51093/4 "2024-04-16T06:07:55Z")

</div>

Thank you for your prompt response. Much appreciated.

I’m not sure I’m up for compiling it myself, but it’s for a school project where it is suggested I use python3.11, so I could be giving it a go!

---

<div class="post-metadata">

**Author:** ![barry-scott](https://avatars.discourse-cdn.com/v4/letter/b/e9c0ed/32.png) [@barry-scott](https://discuss.python.org/u/barry-scott)\
**Post date:** [April 16, 2024, 8:55am UTC](https://discuss.python.org/t/install-python-3-11-9-on-ubuntu/51093/5 "2024-04-16T08:55:21Z")

</div>

> [@kknechtel](#):
>
> In general, _every_ distro can be expected to have this issue with _every package offered_: only specific versions are available in the package repository, because those are the ones that the distro maintainers have pre-built for you.

The Fedora python team packages the latest python at the time that a Fedora release is made as the system’s python. Fedora 39 has 3.12 for example and Fedora 41 is expected to get 3.13.

They also package many of the pervious versions as well.  
At the moment that is python 3.6 through to python 3.11, but they do not package the PyPI packages for these versions.

I find this is very useful for testing my python packages against old versions.

---

<div class="post-metadata">

**Author:** ![FelixFourcolor](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/felixfourcolor/32/13104_2.png) [@FelixFourcolor](https://discuss.python.org/u/FelixFourcolor)\
**Post date:** [April 16, 2024, 12:23pm UTC](https://discuss.python.org/t/install-python-3-11-9-on-ubuntu/51093/6 "2024-04-16T12:23:57Z")

</div>

Does it have to be Ubuntu 22.04 for some reason? Because if you use a later version of Ubuntu such as 23.10, or a distro with newer packages such as Fedora, you will have python 3.11 out of the box.

---

<div class="post-metadata">

**Author:** ![MirkoK](https://avatars.discourse-cdn.com/v4/letter/m/5f8ce5/32.png) [@MirkoK](https://discuss.python.org/u/MirkoK)\
**Post date:** [April 16, 2024, 7:11pm UTC](https://discuss.python.org/t/install-python-3-11-9-on-ubuntu/51093/7 "2024-04-16T19:11:13Z")

</div>

> Does it have to be Ubuntu 22.04 for some reason? Because if you use a later version of Ubuntu such as 23.10, or a distro with newer packages such as Fedora, you will have python 3.11 out of the box.

I’m on Linux Mint 21.1 which is based on Ubuntu 22.04. Python 3.11  
is in Ubuntu’s “universe” repo and doesn’t need an additional PPA,  
let alone an own build from source.

> I received message:  
> python3.11 is already the latest version (3.11.9-1+jammy1)

So, this indicates, that Python 3.11 is already installed, and the  
confusion comes from running “python3 --version” which “still”  
returns “Python 3.10.12”. It’s the same (similar) here:

```python
[1, 0] mirko@wizbox:[~]$ python3 --version
Python 3.10.6
[1, 0] mirko@wizbox:[~]$ python3.11 --version
Python 3.11.0rc1

```

_Carefully note, that this is absolutely correct and expected –  
this is, how it should be!_

Most modern Linux distros use Python themself and Python 3.10.6 is  
the “system’s Python”. On my (and the OP’s) system, 3.11 is  
installed as an _additional_ version.

Carefully note: Do not replace the system’s python! (symlinking,  
overwriting, etc). The system itself needs 3.10, but you can have  
any other python version installed additionally.

@neil

To use python 3.11, simply call “python3.11” instead of “python3”

---

<div class="post-metadata">

**Author:** ![sr-murthy](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/sr-murthy/32/12476_2.png) [@sr-murthy](https://discuss.python.org/u/sr-murthy)\
**Post date:** [April 16, 2024, 8:13pm UTC](https://discuss.python.org/t/install-python-3-11-9-on-ubuntu/51093/8 "2024-04-16T20:13:11Z")

</div>

You could also use [pyenv](https://github.com/pyenv/pyenv) to install and work with multiple versions of Python, without the burden of trying to build specific versions yourselves from source.

Any supported version that is requested for installation is built from source during the installation process, and this requires Python build dependencies (for Mac this includes `zlib`, `ncurses`, and a few others I think), but there is an installer which you can use (below), and I think it will preinstall these dependencies for you, in addition to `pyenv`:

```shell
curl https://pyenv.run | bash

```

I’m on a Mac, so I installed mine via Homebrew - I have never used the installer directly, but I believe it can also manage updates with `pyenv update`.

Once `pyenv` is installed, run this

```shell
pyenv versions

```

to list all installed versions - for you initially it should be your `3.10.12` installation (which should be labelled as `"system"`, depending on what your `PATH` looks like).

Then you can install `3.11.9` with:

```shell
pyenv install "3.11.9"

```

I think `3.11.9` was only added very [recently](https://github.com/pyenv/pyenv/pull/2938). Versions are installed to `~/.pyenv/versions`, and your `3.11.9` bin should be located at:

```shell
~/.pyenv/versions/3.11.9/bin/python3.11

```

To get the latest supported versions keep your `pyenv` up-to-date - with the installer I think this would be with `pyenv update`. Supported versions can be listed with:

```shell
pyenv install --list

```

---

<div class="post-metadata">

**Author:** ![neil](https://avatars.discourse-cdn.com/v4/letter/n/839c29/32.png) [@neil](https://discuss.python.org/u/neil)\
**Post date:** [April 16, 2024, 10:00pm UTC](https://discuss.python.org/t/install-python-3-11-9-on-ubuntu/51093/9 "2024-04-16T22:00:25Z")

</div>

Thank you for all your contributions. What a great community!

It seems I am spoilt for choice.

I have installed Fedora 39 as a guest in Virtual Box.

> uname -a  
> Linux fedora 6.5.6-300.fc39.x86\_64

> python --version  
> Python 3.12.0

I am very happy to work on from here myself, trying some of the different suggestions, and learning as I go.

One unimportant (to me) footnote.  
Fedora took much, much longer to install in Virtual Box than ubuntu.  
(No other apps running in either case.)

FWIW, I followed the steps presented here:

[![](https://us1.discourse-cdn.com/flex002/uploads/python1/original/3X/3/b/3b5c0ce059bcec492ad4af19097dc70168e9ff21.jpeg "How to Install Fedora OS in Virtual Box 2024 (latest version 39) #fedora") ](https://www.youtube.com/watch?v=aLGfzN2IG2I)

because this video was near the top of my google search.

Thanks again.

---

<div class="post-metadata">

**Author:** ![barry-scott](https://avatars.discourse-cdn.com/v4/letter/b/e9c0ed/32.png) [@barry-scott](https://discuss.python.org/u/barry-scott)\
**Post date:** [April 17, 2024, 8:38am UTC](https://discuss.python.org/t/install-python-3-11-9-on-ubuntu/51093/10 "2024-04-17T08:38:59Z")

</div>

> [@neil](#):
>
> Fedora took much, much longer to install in Virtual Box than ubuntu.

Should have taken about the same time. If you want to follow up on this I suggest asking on [https://discussion.fedoraproject.org/](https://discussion.fedoraproject.org/)

---

<div class="post-metadata">

**Author:** ![Kxnr](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/kxnr/32/18937_2.png) [@Kxnr](https://discuss.python.org/u/Kxnr)\
**Post date:** [April 17, 2024, 5:39pm UTC](https://discuss.python.org/t/install-python-3-11-9-on-ubuntu/51093/11 "2024-04-17T17:39:21Z")

</div>

`python3` will continue to point to the default python that comes with the system even once a different version is installed from `deadsnakes` \[1\]. The versions installed from `deadsnakes` are accessible through the longer version name `pythonX.Y`. For example, on my Ubuntu system:

```bash
$ python3 --version
Python 3.10.12

$ python3.7 --version
Python 3.7.17

$ python3.11 --version
Python 3.11.8

```

* * *

1. This is a good thing; there are system programs that depend on python and might break were the python version to change out from under them

---

<div class="post-metadata">

**Author:** ![neil](https://avatars.discourse-cdn.com/v4/letter/n/839c29/32.png) [@neil](https://discuss.python.org/u/neil)\
**Post date:** [April 18, 2024, 1:58am UTC](https://discuss.python.org/t/install-python-3-11-9-on-ubuntu/51093/12 "2024-04-18T01:58:32Z")

</div>

Thank you.

---

<div class="post-metadata">

**Author:** ![brando90](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/brando90/32/21505_2.png) [@brando90](https://discuss.python.org/u/brando90)\
**Post date:** [August 1, 2024, 12:08am UTC](https://discuss.python.org/t/install-python-3-11-9-on-ubuntu/51093/14 "2024-08-01T00:08:36Z")

</div>

This is what actually worked for me:

```python
      apt update -y
      apt install -y software-properties-common
      add-apt-repository ppa:deadsnakes/ppa
      apt update -y
      apt install python3.11

```
