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

IntelliJ运行服务时无法启动Python:找不到Python可执行文件(Mac环境)

解决IntelliJ中无法找到Python可执行文件的问题

错误信息

Error: Can't find Python executable "python", you can set the PYTHON env variable.

解决步骤

1. 确认Mac上Python的实际路径

打开终端,执行以下命令找到Python的安装路径:

which python3
# 或者
which python

通常会得到类似/usr/bin/python3或/usr/local/bin/python3的结果。

2. 方法一:设置PYTHON环境变量

  • 临时生效:在终端执行(替换为你查到的路径):
    export PYTHON=/usr/bin/python3
    
    之后重启IntelliJ即可。
  • 永久生效:编辑shell配置文件(zsh用户编辑~/.zshrc,bash用户编辑~/.bash_profile),添加一行:
    export PYTHON=/usr/bin/python3
    
    保存后执行source ~/.zshrc(对应你的shell文件),再重启IntelliJ。

3. 方法二:直接在IntelliJ中配置Python解释器

  • 打开IntelliJ,进入File > Project Structure > SDKs
  • 点击+按钮,选择Python SDK,定位到终端查到的Python路径并添加
  • 确保项目模块的SDK设置为刚配置的Python解释器

4. 方法三:创建软链接适配python命令

如果系统中只有python3命令没有python,可以在终端执行(需要管理员权限):

sudo ln -s /usr/bin/python3 /usr/bin/python

这样系统会将python命令指向python3,IntelliJ就能识别到。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.04 20:16:04