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. The installer (uv or 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

Choose a stable version supported by the package you need. For the current setup guides, use Python 3.14. Avoid preview releases with a, b, or rc in their version numbers.

For example, installing JupyterLab on Python 3.15.0b1 tried to build PyYAML 6.0.3 from source and crashed with SIGSEGV. The same package installed successfully on Python 3.14 using a prebuilt package. This is one example of a build failure; other errors can have different causes.

Installing and testing

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

uv python install 3.14

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

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

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

Then we'll try to install the jupyterlab package in that Python 3.14 environment.

uv pip install jupyterlab notebook ipykernel

Did it work? Check that JupyterLab can start with python -m jupyterlab --version. A successful install is a good sign; try the imports or notebook code you actually need before switching your main environment.

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 the test worked, follow Upgrading or downgrading your Python version. Those steps save a package list, replace the old data environment, reinstall packages, and register the data kernel again.

Reinstalling packages is necessary: installing another Python does not change the interpreter in an existing environment. Reopen Jupyter or VS Code and select data, then check sys.executable in a notebook to confirm the path.

After returning to your normal environment, you can remove the temporary test environment:

rm -rf ~/.venvs/test-3.14

This removes the test environment and its installed packages, so keep notebooks and project files outside that folder.