Last updated: Apr 9, 2024
Reading timeยท2 min
The error "Could not build wheels for backports.zoneinfo, which is required to
install pyproject.toml-based projects" occurs because the backports.zoneinfo
module doesn't support Python versions greater than 3.9.
To solve the error, use version 3.8
instead.
ERROR: Failed building wheel for backports.zoneinfo Failed to build backports.zoneinfo ERROR: Could not build wheels for backports.zoneinfo, which is required to install pyproject.toml-based projects
The error is caused because the backports.zoneinfo module is not supported in Python 3.9+.
If you got the error when deploying to Heroku:
runtime.txt
file in your app's root directory.python-3.8.15
.
You can view all of the supported runtimes in
this section of the docs.git push heroku master
.The runtime.txt
file is case-sensitive and must not include spaces.
python-3.8.15
Make sure to pick one of the supported runtimes for Python 3.8.X.
If you need to view your local version of Python, run the python --version
command.
python --version
If you don't use Heroku, update your requirements.txt
file and replace the
following line:
backports.zoneinfo==0.2.1
With the following line.
backports.zoneinfo;python_version<"3.9"
This declares a dependency on the backports.zoneinfo module conditional on the Python version.
If you get the error when using docker, use an exact version of Python that is
3.8.X
, e.g. 3.8.15
.
If none of the suggestions helped, you can downgrade your Python version to 3.9.0.
You can check your Python version with the python --version
command.
python --version
Different versions are available in the "Looking for a specific release" table.
If you have Python 3.9.0 installed, you can initialize a virtual environment using the specific version.
# ๐๏ธ Use the correct version of Python when creating VENV python3.9 -m venv venv # ๐๏ธ Activate on Unix or MacOS source venv/bin/activate # ๐๏ธ Activate on Windows (cmd.exe) venv\Scripts\activate.bat # ๐๏ธ Activate on Windows (PowerShell) venv\Scripts\Activate.ps1 # ๐๏ธ Install the specific package in the virtual environment pip install requests
Make sure to use the correct command to activate your virtual environment depending on your operating system and your shell.
Your virtual environment will use the version of Python that was used to create it.
If none of the suggestions helped, try running the pip install
command in
verbose mode.
pip install requests -vvv pip3 install requests -vvv python -m pip install requests -vvv
The -v
option stands for verbose mode and can be used up to 3 times.
When the pip install
command is run in verbose mode, the command shows more
output and how the error occurred.