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 会重新加载包列表

相关推荐
花酒锄作田9 小时前
使用 pkgutil 实现动态插件系统
python
前端付豪12 小时前
LangChain链 写一篇完美推文?用SequencialChain链接不同的组件
人工智能·python·langchain
曲幽13 小时前
FastAPI实战:打造本地文生图接口,ollama+diffusers让AI绘画更听话
python·fastapi·web·cors·diffusers·lcm·ollama·dreamshaper8·txt2img
老赵全栈实战13 小时前
Pydantic配置管理最佳实践(一)
python
阿尔的代码屋19 小时前
[大模型实战 07] 基于 LlamaIndex ReAct 框架手搓全自动博客监控 Agent
人工智能·python
AI探索者2 天前
LangGraph StateGraph 实战:状态机聊天机器人构建指南
python
AI探索者2 天前
LangGraph 入门:构建带记忆功能的天气查询 Agent
python
FishCoderh2 天前
Python自动化办公实战:批量重命名文件,告别手动操作
python
躺平大鹅2 天前
Python函数入门详解(定义+调用+参数)
python
曲幽2 天前
我用FastAPI接ollama大模型,差点被asyncio整崩溃(附对话窗口实战)
python·fastapi·web·async·httpx·asyncio·ollama