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.
Free Download: Click here to download free sample code that demonstrates some of the new features of Python 3.11.
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:
If you want an in-depth tutorial on how to use pyenv
, then check out Managing Multiple Python Versions With pyenv
.
Note: You can identify a pre-release version of Python by looking at the end of its version number. Alpha versions end with a and a number, beta versions with b and a number, and release candidates with rc and a number.
In this tutorial, you’ll see Python 3.11.0rc1 used as an example of a pre-release. rc1 indicates that this is the first release candidate of Python 3.11. However, as you follow along, you should install the latest pre-release version.
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
:
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
:
$ 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:
$ pyenv local 3.11.0rc1
$ python --version
Python 3.11.0rc1
You use pyenv local
to activate your new version inside this directory.
Note:
You can use pip
to install packages into your pre-release version.
However, you may experience that not all projects support the new version yet.
Before installing any dependencies, you should set up a virtual environment as usual. Make sure to use your pre-release version when creating the virtual environment.
On Linux and macOS, there’s an alternative integrated into pyenv
.
You can use the pyenv-virtualenv
plugin to set up virtual environments.
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:
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:
$ 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.
Note:
You can choose a specific pre-release version or use a plain rc
tag that points to the latest pre-release version, including alpha and beta versions.
For example, pulling python:3.11-rc-slim
will give you the latest pre-release version of Python 3.11.
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.
Note: You can also use a different official Docker image designed especially for continuous integration. This image contains several different Python versions, including the latest pre-release.
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.
Note: If you’re using Windows and have several Python versions installed, then you can use the Windows launcher to choose which version to invoke.
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:
$ sudo add-apt-repository ppa:deadsnakes/ppa
$ sudo apt update
You can then search for available Python versions and install the latest pre-release:
$ 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.
Note:
You can invoke different versions of Python by adding the version number to the executable’s name.
For example, python3.11
will run whatever version of Python 3.11 you installed last.
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.
Free Download: Click here to download free sample code that demonstrates some of the new features of Python 3.11.