【发布时间】:2018-11-27 18:05:03
【问题描述】:
我是 MAC 新手(OSX 版本是 High Sierra 10.13.3)。我使用来自 python.org 的安装程序安装了 python 3.6.5,我也尝试通过运行 brew install python 来使用 brew 进行安装。现在,我尝试在 Angular 项目中运行 sudo npm install,但出现以下错误:
gyp verb check python checking for Python executable "/path/to/python3/python" in the PATH
gyp verb `which` failed Error: not found: /path/to/python3/python
gyp ERR! stack Error: Can't find Python executable "/path/to/python3/python", you can set the PYTHON env variable.
我已经尝试了这里的所有答案:
Can't find Python executable "python"
在我的项目文件夹中,我执行以下操作:
当我输入 'which python' 我得到:
/usr/local/opt/python/libexec/bin/python
当我输入“which python3.6.5”时,我得到:
/Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6
【问题讨论】:
-
首先,您已经在 Apple 预装的一个 Python 之上安装了至少两个额外的 Python,而不仅仅是一个。那只会让事情变得更加混乱。卸载其中一个。
-
第二,你有没有把文字字符串
/path/to/python3或/path/to/python3/python放在某个地方?如果是这样,您应该将其替换为 python3 的实际路径,例如/Library/Frameworks/Python.framework/Versions/3.6/bin/或/Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6。 -
@abarnert 正确。我安装了最新版本,因为我知道 MAC 带有默认版本,但是当我运行 npm install 时,它说我需要 python。话虽如此,我在mac的启动器中看到了一个可执行文件,但是当我将它拖到垃圾桶时,它不会被卸载。有什么安全的方法吗?
-
首先,你不能卸载macOS自带的Python,你也不想卸载。但是,您可以卸载两个 Python 3.6 版本中的任何一个。最简单的方法是
brew unlink python,它应该删除 Homebrew 一个,留下 python.org 一个。 -
同时,如果你使用
gyp,AFAIK 那是一个不支持 Python 3 并且永远不会支持的死项目,这意味着安装 Python 3.6 将无济于事。要么使用 Apple 的 Python 2.7,要么安装另一个 Python 2.7。 IIRC,对于前者,它应该像npm install --python=python2.7一样简单。但是,如果您搜索这方面的帮助,而不是实际不需要的 Python 安装帮助,您可能会找到更好的信息。