ERROR pip install_error ai_generated true

ERROR: Package 'X' requires a different Python: X.Y not in '>=3.8,<3.11'

ID: pip/error-installing-package-with-python-version-not-in-range-from-requirements-txt

Also available as: JSON · Markdown · 中文
95%Fix Rate
90%Confidence
1Evidence
2023-07-01First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
pip 20.3+ active
Python 3.8-3.12 active

Root Cause

The current Python interpreter version does not satisfy the package's python_requires constraint specified in its metadata.

generic

中文

当前 Python 解释器版本不满足包元数据中指定的 python_requires 约束。

Official Documentation

https://packaging.python.org/en/latest/specifications/core-metadata/#requires-python

Workarounds

  1. 95% success Create a new virtual environment with a compatible Python version: python3.9 -m venv myenv && source myenv/bin/activate && pip install <package>
    Create a new virtual environment with a compatible Python version: python3.9 -m venv myenv && source myenv/bin/activate && pip install <package>
  2. 90% success Use pyenv to install a compatible Python version: pyenv install 3.10.11 && pyenv local 3.10.11 && pip install <package>
    Use pyenv to install a compatible Python version: pyenv install 3.10.11 && pyenv local 3.10.11 && pip install <package>
  3. 85% success Install an older version of the package that supports your Python version: pip install <package>==<version_that_supports_your_python>
    Install an older version of the package that supports your Python version: pip install <package>==<version_that_supports_your_python>

中文步骤

  1. 创建一个具有兼容 Python 版本的新虚拟环境:python3.9 -m venv myenv && source myenv/bin/activate && pip install <包名>
  2. 使用 pyenv 安装兼容的 Python 版本:pyenv install 3.10.11 && pyenv local 3.10.11 && pip install <包名>
  3. 安装支持您当前 Python 版本的旧版本包:pip install <包名>==<支持您Python的版本>

Dead Ends

Common approaches that don't work:

  1. Using --ignore-requires-python flag to bypass the check 100% fail

    This flag does not exist in pip; it is a common misconception from conda or other tools.

  2. Installing a different version of the package with --no-deps 95% fail

    The python_requires constraint is checked before dependency resolution; --no-deps does not bypass it.

  3. Creating a virtual environment with the same Python version but different name 90% fail

    The Python version in the virtual environment is still the same; the constraint is version-based, not environment-based.