找不到python的节点gyp

发布于 2025-01-22 10:11:32 字数 409 浏览 4 评论 0原文

我正在尝试npm install用于我的Mac中的一个项目,但由于某种原因,即使python3命令都无法正常工作,但我也没有找到python,我还将别名python设置为python3在〜/.zshrc〜/.bash-profile中,并重新启动了几次,但仍然存在同一问题。

该问题的屏幕截图。

注意:请参阅解决方案的评论

I am trying to npm install for a project in my mac but for some reason it says python not found even though python3 command is working fine and I also set alias python to python3 in by ~/.zshrc and ~/.bash-profile and restarted several times but still the same issue.

Screenshot of the issue.

enter image description here

NOTE: See comments for the solution

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

王权女流氓 2025-01-29 10:11:32

问题在于,在系统路径中需要Python才能操作此命令。解决方案:

  1. install pyenv
  2. 安装python 2.7或python 2.7或python 3.x: pyenv install 2.7.18pyenv install 3.9.11(例如)
  3. 如果您有一个以上的python版本,请确保将其中一个设置为global:> pyenv global 3.9.11
  4. 添加pyenv到您的系统路径
    • 在Mac上,将其放入您的〜/.bashrc〜/.zshrcexport path = $(pyenv root)/shims:$ path,然后运行源〜/.bashrcsource〜/.zshrc
    • 对于Windows,尝试npm配置设置Python C:\ library \ Python \ Python310 \ Python.exe(例如)通过管理员
  5. 运行npm安装再次

The problem is that Python is required in the system path to operate this command. Solutions:

  1. Install pyenv
  2. Install either Python 2.7 or Python 3.x: pyenv install 2.7.18 or pyenv install 3.9.11 (for example)
  3. If you have more than one python version, ensure one of them is set as global: pyenv global 3.9.11
  4. Add pyenv to your system path
    • On Mac, put this in your ~/.bashrc or ~/.zshrc: export PATH=$(pyenv root)/shims:$PATH, then run source ~/.bashrc or source ~/.zshrc
    • For Windows, try npm config set python C:\Library\Python\Python310\python.exe (for example) via administrator
  5. Run npm install again
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文