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

PyCharm安装py-pde报错:Python3.9环境却提示版本不兼容

问题

本地Python版本为3.9,在终端执行pip install py-pde可正常安装,但在PyCharm中安装时出现如下报错:

Collecting py-pde
  Using cached py_pde-0.27.1-py3-none-any.whl (269 kB)
Requirement already satisfied: matplotlib>=3.1.0 in /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages (from py-pde) (3.6.2)
Collecting numba>=0.56.0
  Using cached numba-0.56.4.tar.gz (2.4 MB)
  Preparing metadata (setup.py): started
  Preparing metadata (setup.py): finished with status 'error'

  error: subprocess-exited-with-error
  
  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [8 lines of output]
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "/private/var/folders/sl/b99vml7s45q3zx3wb1fqvq240000gp/T/pip-install-pu5ucxpg/numba_1e4a8190083b40fba0897686608f79d0/setup.py", line 51, in <module>
          _guard_py_ver()
        File "/private/var/folders/sl/b99vml7s45q3zx3wb1fqvq240000gp/T/pip-install-pu5ucxpg/numba_1e4a8190083b40fba0897686608f79d0/setup.py", line 48, in _guard_py_ver
          raise RuntimeError(msg.format(cur_py, min_py, max_py))
      RuntimeError: Cannot install on Python version 3.11.0; only versions >=3.7,<3.11 are supported.
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

已通过pip --version确认本地Python版本为3.9,但报错提示无法在Python3.11上安装,请问问题出在哪里,该如何解决?

原因分析

PyCharm当前使用的Python解释器不是终端里的3.9版本,而是系统中的Python3.11。从报错路径/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages可直接看出这一点,而依赖包numba 0.56.4不支持Python3.11,因此安装失败。

解决方法
  • 切换PyCharm的Python解释器
    1. 打开PyCharm,点击顶部菜单栏File→Settings(Windows/Linux)或PyCharm→Settings(Mac)。
    2. 在设置窗口中,选择Project: [你的项目名]→Python Interpreter。
    3. 点击右上角齿轮图标,选择Add。
    4. 在弹出窗口中选择System Interpreter,找到本地Python3.9的安装路径(如/Library/Frameworks/Python.framework/Versions/3.9/bin/python3.9),选中后点击OK。
    5. 返回Python Interpreter页面,确认已切换到3.9版本,点击Apply和OK。
  • 重新安装py-pde
    切换解释器后,可通过PyCharm的终端执行pip install py-pde,或在Python Interpreter页面点击+号,搜索py-pde后点击Install Package完成安装。

内容的提问来源于stack exchange,提问作者Aswin Krishna

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.31 17:55:42