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

Python3.7.15虚拟环境安装pandas==1.3.3失败求助

解决Python3.7.15虚拟环境中安装pandas==1.3.3失败的问题

问题场景

Python版本为3.7.15,通过命令python3 -m venv env && source env/bin/activate创建虚拟环境后,尝试安装pandas==1.3.3时触发以下错误:

Collecting pandas==1.3.3
  Using cached pandas-1.3.3.tar.gz (4.7 MB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... error
  error: subprocess-exited-with-error

  × Getting requirements to build wheel did not run successfully.
  │ exit code: 1
  ╰─> [17 lines of output]
      Traceback (most recent call last):
        File "/Users/user/env/lib/python3.7/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 363, in <module>
          main()
        File "/Users/user/env/lib/python3.7/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 345, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
        File "/Users/user/env/lib/python3.7/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 130, in get_requires_for_build_wheel
          return hook(config_settings)
        File "/private/var/folders/yq/l3rq2lw55t923sygld_4m2rm0000gn/T/pip-build-env-nre30lmt/overlay/lib/python3.7/site-packages/setuptools/build_meta.py", line 338, in get_requires_for_build_wheel
          return self._get_build_requires(config_settings, requirements=['wheel'])
        File "/private/var/folders/yq/l3rq2lw55t923sygld_4m2rm0000gn/T/pip-build-env-nre30lmt/overlay/lib/python3.7/site-packages/setuptools/build_meta.py", line 320, in _get_build_requires
          self.run_setup()
        File "/private/var/folders/yq/l3rq2lw55t923sygld_4m2rm0000gn/T/pip-build-env-nre30lmt/overlay/lib/python3.7/site-packages/setuptools/build_meta.py", line 484, in run_setup
          self).run_setup(setup_script=setup_script)
        File "/private/var/folders/yq/l3rq2lw55t923sygld_4m2rm0000gn/T/pip-build-env-nre30lmt/overlay/lib/python3.7/site-packages/setuptools/build_meta.py", line 335, in run_setup
          exec(code, locals())
        File "<string>", line 18, in <module>
      ModuleNotFoundError: No module named 'numpy'
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.
WARNING: You are using pip version 22.0.4; however, version 22.3.1 is available.
You should consider upgrading via the '/Users/user/env/bin/python -m pip install --upgrade pip' command.

已尝试pip install -U pip升级pip,但问题未解决。

核心原因

报错中ModuleNotFoundError: No module named 'numpy'是关键:pandas 1.3.3在构建wheel的过程中依赖numpy,但旧版本pandas的构建配置未正确声明该前置依赖,导致pip无法自动提前安装numpy。

解决方法

方法一:分步安装

  1. 先安装与Python3.7、pandas1.3.3兼容的numpy版本(推荐numpy==1.21.6):
    pip install numpy==1.21.6
    
  2. 再安装pandas==1.3.3:
    pip install pandas==1.3.3
    

方法二:一次性安装

直接同时指定两个包,让pip处理依赖安装顺序:

pip install numpy==1.21.6 pandas==1.3.3

额外说明

  • 升级pip无效是因为问题根源并非pip版本,而是pandas旧版本的构建依赖声明缺陷。
  • 操作时确保虚拟环境处于激活状态,避免修改全局Python环境。

内容的提问来源于stack exchange,提问作者A. Veselev

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.13 05:55:19