You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

无法为Python 2安装Mapping库:oldest-supported-numpy匹配失败

问题:Python 2环境下pip安装Mapping库失败

尝试通过pip为Python 2安装Mapping库时,出现如下错误:

ERROR: Command errored out with exit status 1:
   command: /home/pavloh/miniconda3/envs/deezer2/bin/python2.7 /home/pavloh/miniconda3/envs/deezer2/lib/python2.7/site-packages/pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-eWQJap/overlay --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple -- wheel setuptools oldest-supported-numpy
       cwd: None
  Complete output (7 lines):
  DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
  Collecting wheel
    Using cached wheel-0.37.1-py2.py3-none-any.whl (35 kB)
  Collecting setuptools
    Using cached setuptools-44.1.1-py2.py3-none-any.whl (583 kB)
  ERROR: Could not find a version that satisfies the requirement oldest-supported-numpy (from versions: none)
  ERROR: No matching distribution found for oldest-supported-numpy

当前环境已安装numpy,完整包列表如下:

_libgcc_mutex             0.1                 conda_forge    conda-forge
_openmp_mutex             4.5                       2_gnu    conda-forge
ca-certificates           2022.9.24            ha878542_0    conda-forge
certifi                   2019.11.28       py27h8c360ce_1    conda-forge
httplib2                  0.20.4                   pypi_0    pypi
ld_impl_linux-64          2.36.1               hea4e1c9_2    conda-forge
libffi                    3.2.1             he1b5a44_1007    conda-forge
libgcc-ng                 12.1.0              h8d9b700_16    conda-forge
libgomp                   12.1.0              h8d9b700_16    conda-forge
libsqlite                 3.39.4               h753d276_0    conda-forge
libstdcxx-ng              12.1.0              ha89aaad_16    conda-forge
libzlib                   1.2.12               h166bdaf_4    conda-forge
ncurses                   6.3                  h27087fc_1    conda-forge
openssl                   3.0.5                h166bdaf_2    conda-forge
pip                       20.1.1             pyh9f0ad1d_0    conda-forge
pyparsing                 2.4.7                    pypi_0    pypi
python                    2.7.18               h02575d3_0
python_abi                2.7                    1_cp27mu    conda-forge
readline                  8.1.2                h0f457ee_0    conda-forge
setuptools                44.0.0                   py27_0    conda-forge
sqlite                    3.39.4               h4ff8645_0    conda-forge
tk                        8.6.12               h27826a3_0    conda-forge
wheel                     0.37.1             pyhd8ed1ab_0    conda-forge
zlib                      1.2.12               h166bdaf_4    conda-forge

解决建议

  • 核心原因:oldest-supported-numpy 本身不支持Python 2,它是为Python 3环境设计的版本适配工具,而Mapping库的安装脚本依赖这个包,导致安装失败。
  • 绕过构建隔离环境:安装时添加--no-build-isolation参数,避免pip自动安装不兼容的依赖包,命令如下:
    pip install Mapping --no-build-isolation
    
  • 指定兼容版本安装:查找支持Python 2的Mapping库历史版本,直接指定版本号安装,例如:
    pip install Mapping==<兼容版本号>
    
  • 替换为替代库:如果Mapping库已停止Python 2支持,可使用标准库中的collections.Mapping(若满足功能需求)或其他同类型兼容库。
  • 长期方案:Python 2已停止维护多年,多数新包不再支持,建议迁移到Python 3环境。

内容的提问来源于stack exchange,提问作者Pavlo Hrab

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.17 12:30:54