Pycharm 选择Python Interpreter
你的系统可能有多个 Python 环境,比如:
macOS 自带的 /usr/bin/python3
你用 brew install python 安装的 /opt/homebrew/bin/python3
你可能还用了虚拟环境(venv 或 conda)
PyCharm 默认配置可能用的是一个虚拟环境,但你用 Terminal 装包时用了另一个
所以你终端里用 pip install 装了包,但 PyCharm 里其实没在用那个 Python。
✅ 解决方案:确认 PyCharm 用的解释器
打开 PyCharm 的设置:
macOS 上是:PyCharm → Preferences → Project: xxx → Python Interpreter
检查当前解释器路径,例如:
swift
复制
编辑
/opt/homebrew/bin/python3.11
/Users/you/project/venv/bin/python
/usr/bin/python3
对比你在终端里执行这个命令的输出:
bash
复制
编辑
which python3
which pip3
看看是不是和 PyCharm 配置的路径一致。
✅ 如果你想统一使用终端里的解释器:
你可以把 PyCharm 的解释器改成终端里那个:
点 Interpreter 设置页面右上角齿轮 → Add…
选择 System Interpreter
选择你在终端用的那个路径(which python3 给你的路径)
点 OK,PyCharm 会重新加载包列表