python config_error ai_generated true

需求已满足:numpy 位于 /usr/lib/python3/dist-packages (1.21.5),但你使用 Python 3.11 且 numpy 无法导入

Requirement already satisfied: numpy in /usr/lib/python3/dist-packages (1.21.5) but you have python 3.11 and numpy is not importable

ID: python/pip-requirement-already-satisfied-wrong-python

其他格式: JSON · Markdown 中文 · English
80%修复率
87%置信度
0证据数
2024-07-04首次发现

版本兼容性

版本状态引入弃用备注
3.9 active — — —
3.10 active — — —
3.11 active — — —
3.12 active — — —

根因分析

pip 正在针对不同 Python 版本的 dist-packages 目录进行解析。通常由 pip 与 Python 不匹配(例如 pip 指向系统 Python,而你运行的是 pyenv Python),或 PYTHONPATH 泄漏引起。

English

pip is resolving against a dist-packages directory for a different Python version. Usually caused by a mismatched pip (e.g. pip points to system Python while you run a pyenv Python), or PYTHONPATH leaking.

generic

解决方案

  1. 98% 成功率
    python3.11 -m pip install numpy
  2. 95% 成功率
    which -a pip python && pip -V && python -V
  3. 98% 成功率
    python3.11 -m venv .venv && source .venv/bin/activate && pip install numpy

无效尝试

常见但无效的做法:

  1. 85% 失败

    Still installs into the wrong interpreter's site-packages.

  2. 95% 失败

    Makes things worse by mixing ABI-incompatible C extensions.