How Can You Install a Pre-Release Version of Python?

How Can You Install a Pre-Release Version of Python?

The Python language is in constant development. A new version is released annually in October to great fanfare. Before these stable releases, you can preview the new features by installing a pre-release of Python.

Volunteers worldwide work on developing Python by updating the documentation, reporting issues, suggesting and discussing improvements, fixing bugs, and implementing new features. You can join this work and contribute to the efforts.

The best way to start getting involved in the development of Python is to install and test early versions of the next release, whether it’s in the alpha, beta, or release candidate phase. Pablo Galindo Salgado, the release manager for Python 3.10 and 3.11, put it succinctly:

In summary: no matter who you are or what you do. Test the beta releases! (Source)

Python is essential to many people’s workflows and companies’ infrastructures. Therefore, the community must thoroughly test new Python versions before the stable release. You use Python differently from anyone else and may be able to reveal a bug that no one else has discovered. Installing a pre-release version of Python and playing with it is valuable to the ecosystem. Plus, it’s fun!

You’re excited to install an early version of Python and try out the latest features. One question remains: How can you install a pre-release version of Python?

In this tutorial, you’ll learn about some options for getting your hands on an early version of Python and previewing its features.

In Short: Use pyenv to Manage Several Versions of Python, Including the Latest Pre-Release

You shouldn’t use a pre-release version of Python as the only Python on your computer. By their nature, pre-releases may be unstable or have bugs that can interfere with your day-to-day Python work. You should therefore install the pre-release version side by side with your regular Python.

One great tool for installing and managing several versions of Python on your computer is pyenv. With pyenv, you can install many Python versions on your computer and switch between them with a simple command. You can even set up project-specific Python versions that are automatically invoked.

If you’re not already using pyenv, then you first need to install it. How you install pyenv depends on your operating system. Choose your platform with the switcher below:

On Windows, you should use the pyenv for Windows fork. The documentation guides you through the installation process. Check out Your Python Coding Environment on Windows: Setup Guide for more information about integrating pyenv into your system.

On Linux and macOS, you can install pyenv directly by following the instructions in the documentation. A good option is to use the pyenv-installer.

If you want an in-depth tutorial on how to use pyenv, then check out Managing Multiple Python Versions With pyenv.

Once you’ve installed pyenv, then you’re ready to install the latest pre-release version of Python. First, you should update pyenv and its index of available Python versions. Open a terminal and run pyenv update:

Windows PowerShell
PS> pyenv update
:: [Info] ::  Mirror: https://www.python.org/ftp/python
[...]

Doing an update ensures that you have access to the latest pre-release versions of Python. You could also update pyenv manually.

Use pyenv install --list to check which versions of Python are available. Install the latest pre-release version:

Windows PowerShell
PS> pyenv install 3.11.0rc1
:: [Info] ::  Mirror: https://www.python.org/ftp/python
:: [Downloading] ::  3.11.0rc1 ...
[...]
Shell
$ pyenv update
Updating /home/realpython/.pyenv...
[...]

Doing an update ensures that you have access to the latest pre-release versions of Python. Depending on how you installed pyenv, you may need to install the pyenv-update plugin to run pyenv update. Alternatively, you can update pyenv manually.

Use pyenv install --list to check which versions of Python are available. The list will be long because pyenv supports lots of different Python implementations. Look for the unnamed versions near the top of the list. From those, choose and install the latest pre-release version:

Shell
$ pyenv install 3.11.0rc1
Downloading Python-3.11.0rc1.tar.xz...
[...]

The installation may take a few minutes. Once you’ve installed your new version, you should take it for a spin. One nice feature of pyenv is that it can switch versions based on which directory you start Python from. Create a new directory that you can use for testing. Because it’s a place for you to play, you can call it sandbox:

Shell
$ mkdir sandbox
$ cd sandbox/

After you’ve created and entered your sandbox directory, you can tell pyenv that you want to use your new pre-release version:

Shell
$ pyenv local 3.11.0rc1
$ python --version
Python 3.11.0rc1

You use pyenv local to activate your new version inside this directory.

Using pyenv is excellent for trying out different versions of Python. New versions are readily available, and the tool ensures that your experiments don’t interfere with your day-to-day coding duties and adventures.

While pyenv is great, you do have a few alternatives that may fit your workflow better. In the rest of this tutorial, you’ll learn about other ways to install pre-releases. These approaches require you to be more hands-on when managing your coding environment.

How Can You Install Pre-Release Versions From python.org?

Python’s main home on the Internet is at python.org. You can always go there to find the latest versions of Python, including the pre-releases. You’ll find a list of available releases for your system:

Technically, there are no specific Linux releases. Instead, you’ll install Python from source if you’re on Linux. You can also use these source files on other platforms.

Each of the pages listed above shows both pre-releases and stable releases. You can also look at the dedicated pre-releases page to focus only on those. To get there from the home page, you can click on Downloads and then Prereleases:

Screenshot Showing Navigation to Prerelease Page on python.org

Once you’ve navigated to the version of Python that you’re interested in, you can scroll down to the Files section at the bottom of the page. Then, download the file corresponding to your system. See Python 3 Installation & Setup Guide for details on how to do the installation on Windows, Linux, or macOS.

Installing from python.org is a good alternative for getting pre-releases of Python onto your system. However, you need to manage your different versions of Python manually. For example, you should ensure that you don’t overwrite other versions, and you can use a launcher to choose which version to invoke.

In the next section, you’ll see how you can install Python so that it’s isolated from the rest of your system.

How Can You Use Docker to Test Early Versions of Python?

Docker is a virtualization platform that’s often used for portable application development and deployment. If you already have access to Docker on your system, then this is an excellent alternative for testing new versions of Python.

Docker uses the concept of images and containers. A Docker image is a kind of blueprint encapsulating all the resources needed to run an application. A container is a runnable instance of an image. To try out an early version of Python, you can download an image from the Python repository and run it as a container on your system.

Official Python images are hosted on Docker Hub. Tags identify different images. Docker Hub also provides a list of which tags are available. To use a Docker image, you first pull it from the repository, and then you run it:

Shell
$ docker pull python:3.11.0rc1-slim
3.11.0rc1-slim: Pulling from library/python
[...]
docker.io/library/python:3.11.0rc1-slim

$ docker run -it --rm python:3.11.0rc1-slim

This command drops you into a Python REPL. The -it option is necessary when using a container interactively, while --rm conveniently cleans up the container when you exit the REPL.

Images labeled slim are smaller than regular images. They’re lacking some tools that usually aren’t relevant when you’re running Python.

Running scripts with Python through Docker is a bit different from what you’re probably used to. Check out Run Python Versions in Docker for more information. Editors like Visual Studio Code and Pycharm provide special support for working with Docker containers.

If you already have Docker installed on your system, then it’s straightforward to pull down the latest pre-release version of Python and play with it. In the next section, you’ll see one final alternative for installing early versions of Python.

How Can You Use Your Operating System’s Package Manager?

Each major platform has different package managers that you can use to install software. A few of these—the Microsoft Store for Windows and the deadsnakes repository for Ubuntu, for example—allow you to install early versions of Python. Homebrew for macOS typically doesn’t provide pre-release versions of Python.

The Microsoft Store is an app store where you can download different tools and applications for Windows. Among the available free downloads are pre-release versions of Python. To find and install these, search for Python and look for the latest version.

If you’re using Linux Ubuntu, then the deadsnakes repository can provide many different Python versions. To use deadsnakes, you first need to add the repository to your apt package manager:

Shell
$ sudo add-apt-repository ppa:deadsnakes/ppa
$ sudo apt update

You can then search for available Python versions and install the latest pre-release:

Shell
$ apt search "^python3\."
python3.11/focal 3.11.0~rc1-1+focal1 amd64
  Interactive high-level object-oriented language (version 3.11)

python3.11-dev/focal 3.11.0~rc1-1+focal1 amd64
  ...

$ sudo apt install python3.11
...

This installs the latest pre-release of Python to your Ubuntu system. You can find an overview of which Python versions deadsnakes currently supports at their archive.

Using your operating system’s package manager to install the newest version of Python can be a convenient option if it’s supported.

Conclusion

Trying out the latest pre-release version of Python is fun! You get to play with some features before they’re officially released. It’s also beneficial to the Python community because the more bugs and issues surface and get fixed during development, the more stable the final release will be.

In this tutorial, you’ve learned how you can install a pre-release version of Python. The best option is to use pyenv because that tool also manages your different versions of Python. This means that you can use the latest pre-release version side by side with your regular workhorse version.

You may encounter weird issues and bugs when trying an early Python release. You can report such bugs at the Python repository on GitHub.

🐍 Python Tricks 💌

Get a short & sweet Python Trick delivered to your inbox every couple of days. No spam ever. Unsubscribe any time. Curated by the Real Python team.

Python Tricks Dictionary Merge

About Geir Arne Hjelle

Geir Arne Hjelle Geir Arne Hjelle

Geir Arne is an avid Pythonista and a member of the Real Python tutorial team.

» More about Geir Arne

Each tutorial at Real Python is created by a team of developers so that it meets our high quality standards. The team members who worked on this tutorial are:

Master Real-World Python Skills With Unlimited Access to Real Python

Locked learning resources

Join us and get access to thousands of tutorials, hands-on video courses, and a community of expert Pythonistas:

Level Up Your Python Skills »

Master Real-World Python Skills
With Unlimited Access to Real Python

Locked learning resources

Join us and get access to thousands of tutorials, hands-on video courses, and a community of expert Pythonistas:

Level Up Your Python Skills »

What Do You Think?

Rate this article:

What’s your #1 takeaway or favorite thing you learned? How are you going to put your newfound skills to use? Leave a comment below and let us know.

Commenting Tips: The most useful comments are those written with the goal of learning from or helping out other students. Get tips for asking good questions and get answers to common questions in our support portal.


Looking for a real-time conversation? Visit the Real Python Community Chat or join the next “Office Hours” Live Q&A Session. Happy Pythoning!

Keep Learning

Related Tutorial Categories: advanced devops docker tools