Skip to content

Check if a package will install in another version of Python

Also known as (potentially) solving the "Could not build wheels for [package]" error message.

The problem

Sometimes when you try to install a package you get an error. What's the error? Could be anything!

A big one is "could not build wheels for [package]," which means two things:

  1. pip couldn't find a version of the package pre-built for your system (combination of your Python version + your operating system)
  2. It tried to take the source code and turn it into a package, but something went wrong.

Figuring out the second half is probably the "correct" way to fix things long term, but changing your Python version is often a quicker fix if there happens to be a pre-built version for another.

Update uv

Did you install Python using uv?. I hope so, because we're going to take advantage of that!

We'll start by updating uv so it knows about recent Python releases.

brew upgrade uv
winget upgrade --id=astral-sh.uv -e --source winget

Determining which other Python version to try

First, check the version of Python you're running:

python --version

Then, find the versions of Python that uv knows about:

uv python list

Scroll all the way up to the top to see something that looks a little bit earlier than yours.

For example, if I'm using Python 3.13 I might want to dial back to Python 3.12.

Installing and testing

Since we are interested in scaling back to Python 3.12, we'll start by installing Python 3.12 with uv.

uv python install 3.12

Then we'll make a temporary environment that uses Python 3.12, and turn it on.

uv venv ~/.venvs/test-3.12 --python 3.12 --seed
source ~/.venvs/test-3.12/bin/activate
uv venv ~/.venvs/test-3.12 --python 3.12 --seed
source ~/.venvs/test-3.12/Scripts/activate

You should see (test-3.12) at the beginning of your command line instead of (data).

Then we'll try to install the dedupe package in that Python 3.12 environment.

pip install dedupe

Did it work? Great, now we know Python 3.12 is the answer!

When you're done testing, close your command line and open a new one. You'll be back to your normal (data) environment.

Switching your main environment

If you decide you want to use Python 3.12 for everything, you can rebuild your data environment with the older Python. This deletes everything you've installed, so you'll need to reinstall your packages afterwards.

uv venv ~/.venvs/data --python 3.12 --seed --clear

Then close your command line, open a new one, and reinstall what you need:

pip install jupyterlab notebook requests bs4 pandas dedupe

Your data kernel in Jupyter and VS Code will automatically use the new Python, since it's living in the same place as the old one.

To get rid of the test environment, you can delete it:

rm -rf ~/.venvs/test-3.12