pip._internal.exceptions.InstallationError: X is not a supported wheel on this platform.
Encountering "X is not a supported wheel on this platform" means pip cannot install a Python wheel package due to an incompatibility with your operating system or Python version; this guide explains how to fix it.
What This Error Means
This pip._internal.exceptions.InstallationError is a clear signal that pip, Python's package installer, has encountered a pre-compiled Python package (known as a "wheel") that isn't compatible with your current Python environment. Specifically, "X" refers to the name of the package you're trying to install, and "not a supported wheel on this platform" means the .whl file pip found (or was directed to) does not match the system's operating system, CPU architecture, or the Python version it's running on.
A Python wheel (.whl) is a pre-built distribution format designed to make installations faster and more reliable by avoiding the need to compile code during installation. These wheels are built for specific environments. For example, a wheel named mypackage-1.0-cp39-cp39-win_amd64.whl is built for CPython 3.9 on a 64-bit Windows system. If you try to install this on a Linux machine with Python 3.10, you'll hit this error.
Why It Happens
The core reason this error occurs is a mismatch between the desired package's pre-compiled binaries and your system's specifics. Python, despite its cross-platform nature, often relies on underlying C, C++, or Fortran libraries for performance-critical operations (e.g., in data science packages like NumPy or SciPy). These compiled components are platform-dependent.
When you run pip install some_package, pip tries to find a compatible wheel for your exact Python version, operating system, and architecture. If it can't find one, or if you explicitly try to install an incompatible one, this error is raised. In my experience, it's often a case of trying to install a Windows-specific wheel on Linux, or an older Python 3.8 wheel into a Python 3.10 environment.
Common Causes
This error usually stems from one of these scenarios:
- Python Version Mismatch: The wheel was built for a different Python interpreter version (e.g.,
cp38for Python 3.8,cp39for Python 3.9, etc.), and your currentpythonexecutable is a different version. - Operating System Mismatch: The wheel is compiled for a different OS (e.g.,
win_amd64for Windows,linux_x86_64for Linux,macosx_10_9_x86_64for macOS Intel), and you are on another. - CPU Architecture Mismatch: This is increasingly common with the rise of ARM-based CPUs (like Apple Silicon M1/M2/M3 Macs) alongside traditional x86_64 (Intel/AMD) architectures. A wheel built for
manylinux_x86_64won't work on anaarch64Linux system unless it's a "pure Python" wheel or specifically compiled for ARM. - Outdated
piporsetuptools: Sometimes, older versions of pip or setuptools might not correctly identify your platform or might not be able to handle newer wheel formats. This is less common now but I've seen it surface in older CI/CD pipelines. - Incorrect Virtual Environment: You might be activating one virtual environment but running
pipfrom another, or your virtual environment might be tied to a different Python version than you intend. - Direct Installation of an Incompatible Wheel: If you're manually downloading a
.whlfile and trying to install it viapip install path/to/some_package.whl, and that specific file isn't compatible with your system, this error will appear.
Step-by-Step Fix
Solving this issue involves systematically checking your environment and ensuring you're requesting a compatible package.
Step 1: Understand Your Current Environment
First, determine the specifics of your current Python interpreter and operating system. This is crucial for matching against available wheels.
- Check Python Version:
bash python --version # Example output: Python 3.9.7 - Check Operating System and Architecture:
bash python -c "import platform; print(f'OS: {platform.system()} {platform.release()} ({platform.machine()})')" # Example output: OS: Linux 5.15.0-79-generic (x86_64) # Or for macOS: OS: Darwin 22.6.0 (arm64) - Use
pip debugfor detailed platform tags: This command is incredibly useful as it shows the "tags" that pip is looking for.
bash python -m pip debug --verbose
Look for the "Compatible tags" section. These are the specific identifiers (e.g.,cp39-cp39-linux_x86_64,py3-none-any) that pip uses to find compatible wheels.
Step 2: Update pip, setuptools, and wheel
An outdated pip can sometimes misidentify platforms or have issues with newer wheel formats. Always start with an update.
python -m pip install --upgrade pip setuptools wheel
Step 3: Verify Package Compatibility
Go to the package's page on PyPI (e.g., pypi.org/project/your_package_name/). Look for the "Download files" section under the "Release history" tab. Here, you'll see a list of available wheels and their compatibility tags.
Compare these tags with the "Compatible tags" you found in Step 1.
* cpXX: Matches your Python version (e.g., cp39 for Python 3.9).
* abiXX: Application Binary Interface (e.g., cp39 matching the Python version is common).
* platform: Matches your OS and architecture (e.g., linux_x86_64, win_amd64, macosx_10_9_x86_64, macosx_11_0_arm64).
If you don't see a wheel that matches your exact platform tags, that's your problem.
Step 4: Try Installing a Source Distribution (if available)
If no compatible wheel is found, the package might offer a "source distribution" (.tar.gz or .zip file). Pip can attempt to build the package from source. This requires a C compiler (like GCC or Clang) and potentially development headers for any underlying C libraries.
python -m pip install --no-binary :all: <package_name>
The --no-binary :all: flag tells pip to not use any pre-compiled wheels, forcing it to attempt a source build. Be prepared for new errors if you're missing build tools. On Debian/Ubuntu, you might need sudo apt-get install build-essential python3-dev. On Fedora, sudo dnf install @development-tools python3-devel. On macOS, Xcode Command Line Tools are often required (xcode-select --install). On Windows, Visual C++ Build Tools might be needed.
Step 5: Use a Compatible Python Environment or Package Version
If steps 1-4 don't yield a solution, you might need to adjust your environment:
- Switch Python Versions: If the package heavily relies on C extensions and only supports certain Python versions (e.g., up to 3.9), you might need to use
pyenv,conda, orvirtualenvto create an environment with a compatible Python version. - Downgrade/Upgrade Package: Check if an older or newer version of the package has wheels compatible with your setup. Use
pip install <package_name>==<version>. - Consider Alternative Packages: In rare cases, if a package is severely unsupported for your platform, you might need to find an alternative.
Step 6: Address Specific Architecture/OS Issues
- Apple Silicon (M1/M2/M3 Macs): Many packages now offer
arm64wheels (e.g.,macosx_11_0_arm64). If not, you might be running Python under Rosetta 2 (emulating x86_64), which can then usex86_64wheels, but this is less efficient. Ensure your Python installation is nativearm64if you want nativearm64wheels.conda(Miniforge) offers excellent native ARM support. - Windows Subsystem for Linux (WSL): This behaves like a Linux environment. Ensure you're installing Linux wheels (
manylinux,linux_x86_64, etc.), not Windows ones.
Code Examples
1. Identifying Your Platform Tags
# Check Python version
python --version
# Check OS and architecture
python -c "import platform; print(f'OS: {platform.system()} {platform.release()} ({platform.machine()})')"
# Get detailed pip compatibility tags
python -m pip debug --verbose
Example Output for pip debug --verbose (relevant part):
...
Compatibility tags:
cp39-cp39-linux_x86_64
cp39-abi3-linux_x86_64
cp39-none-linux_x86_64
cp38-abi3-linux_x86_64
cp37-abi3-linux_x86_64
cp36-abi3-linux_x86_64
pp39-pypy_400-linux_x86_64
py39-none-linux_x86_64
py3-none-linux_x86_64
py38-none-linux_x86_64
py37-none-linux_x86_64
py36-none-linux_x86_64
py35-none-linux_x86_64
py34-none-linux_x86_64
py33-none-linux_x86_64
py32-none-linux_x86_64
py31-none-linux_x86_64
py30-none-linux_x86_64
pygon-none-linux_x86_64
py-none-linux_x86_64
cp39-none-any
py39-none-any
py3-none-any
py-none-any
...
2. Updating pip and Forcing Source Install
# Ensure pip, setuptools, and wheel are up-to-date
python -m pip install --upgrade pip setuptools wheel
# Attempt to install a package, forcing a source build
# Replace 'problematic-package' with the actual package name
python -m pip install --no-binary :all: problematic-package
3. Example Scenario: Installing some-complex-library for Python 3.10 on Linux x86_64
Let's say you're on a Linux x86_64 machine with Python 3.10, and you get the error when trying pip install some-complex-library.
- Check your environment:
bash python --version # Python 3.10.6 python -m pip debug --verbose # Shows cp310-cp310-linux_x86_64 as top tag - Check PyPI for
some-complex-library: You find that the latest release only has wheels likesome_complex_library-1.0-cp39-cp39-linux_x86_64.whlandsome_complex_library-1.0-cp38-cp38-win_amd64.whl. There's nocp310wheel for Linux. - Potential Solutions:
- Option A: Force Source Build (if source distribution is available):
bash python -m pip install --no-binary :all: some-complex-library # You might need to install build tools first, e.g., # sudo apt-get update && sudo apt-get install build-essential python3-dev - Option B: Use a compatible Python version (if possible):
If you havepyenvinstalled, you might switch to Python 3.9:
bash pyenv local 3.9.16 # Activate virtual environment tied to 3.9 python -m pip install some-complex-library - Option C: Look for a newer version of the library (or pre-release): Sometimes a beta version or an unreleased commit might have compatible wheels.
- Option A: Force Source Build (if source distribution is available):
Environment-Specific Notes
The "platform" can be more complex than just your local machine.
-
Cloud Environments (e.g., AWS Lambda, Google Cloud Functions, Azure Functions): These typically run on Linux (often
x86_64, but increasinglyarm64). When youpip installpackages for deployment, you must ensure the wheels are compatible with the cloud environment's OS and architecture, not necessarily your local development machine. I've often seen this when developing on macOS and deploying to Lambda: you might need to build your dependency package in a Docker container that mimics the Lambda environment to get compatiblemanylinuxwheels. Usingpip install --platform manylinux2014_x86_64 --target ./package --python-version 3.9 --only-binary :all: <package>can help. -
Docker Containers: The base image of your Dockerfile determines the platform. If your base image is
python:3.9-slim-buster(Debian-based,x86_64), ensure you're installing packages compatible with that specific Linux distribution and architecture. If you're building forarm64(e.g.,python:3.9-slim-bullseye-arm64v8), the wheels must match. Multi-stage builds are excellent for this: build wheels in one stage with specific platform tools, then copy them to a smaller runtime image. -
Local Development (macOS, Windows, Linux):
- Virtual Environments: Always use
virtualenvorvenvto isolate your project dependencies. This prevents global conflicts and ensurespipinstalls packages for the specific Python interpreter tied to that environment. - Apple Silicon (M1/M2/M3): If you're encountering issues here, double-check if your Python interpreter is running natively (arm64) or via Rosetta 2 (x86_64 emulation).
arch -arm64 pythonorarch -x86_64 pythoncan force the architecture for a single command. Many developers useminiforgeorcondato manage Python environments on Apple Silicon, as they often have better support for nativearm64binaries. I recall a time whentensorflowon M1 Macs required very specific Conda builds because official wheels weren't available for a while.
- Virtual Environments: Always use
Frequently Asked Questions
Q: What exactly is a "wheel" and why does it matter for compatibility?
A: A Python "wheel" (.whl file) is a pre-built distribution format for Python packages. It matters for compatibility because it contains pre-compiled code (for performance-critical parts of libraries), which is specific to a particular Python version, operating system, and CPU architecture. This means a wheel for Windows won't work on Linux, and a wheel for Python 3.8 won't work on Python 3.10.
Q: How do I find out what "platform tags" my Python environment supports?
A: The most reliable way is to run python -m pip debug --verbose. Look for the "Compatible tags" section. These tags list the specific combinations of Python version, ABI (Application Binary Interface), and platform (OS and architecture) that your pip installation can recognize.
Q: Can I just force pip to install an incompatible wheel?
A: No, pip will not allow you to directly install a wheel that it identifies as incompatible using its standard methods, as it would likely lead to runtime errors or crashes. The closest you can get is using pip install --no-binary :all: <package_name> to force an installation from a source distribution, which means compiling it on your system, bypassing the wheel's pre-compiled binaries entirely.
Q: I'm on an Apple Silicon (M1/M2) Mac and keep getting this error. What's the best approach?
A: First, ensure your Python installation is native arm64. If it's an x86_64 Python running under Rosetta 2, you'll need x86_64 wheels. For native arm64 Python, look for wheels ending in macosx_11_0_arm64 or macosx_12_0_arm64, etc. Often, conda (specifically miniforge) provides a more robust ecosystem for native Apple Silicon Python packages and their dependencies. If no arm64 wheel is available, trying a source build with xcode-select --install and --no-binary :all: is your next best bet.
Q: What if a package simply doesn't have a compatible wheel or source distribution for my setup?
A: If a package genuinely lacks a compatible wheel or source distribution that can be built on your system, you have limited options. You might need to:
1. Use a different Python version or operating system for that specific project.
2. Search for an alternative package that provides similar functionality but supports your environment.
3. If it's an open-source project, consider contributing by creating a compatible wheel or fixing the source build process.
This is a common pitfall I've encountered with niche scientific libraries.
Related Errors
(none)