Error:Can‘t find Python executable “/path/to/executable/python2.7“, you can set the PYTHON env varia

曾经终败给现在 2023-09-30 07:14 116阅读 0赞

vue前端项目执行 npm install时报错如下:

  1. gyp ERR! configure error
  2. gyp ERR! stack Error: Can't find Python executable "python2.7", you can set the PYTHON env variable.

watermark_type_d3F5LXplbmhlaQ_shadow_50_text_Q1NETiBATWluZ2dlUWluZ2NodW4_size_20_color_FFFFFF_t_70_g_se_x_16

因看node-gyp的安装需求,https://github.com/nodejs/node-gyp, 部分剪切如下,可以请求的看到需要安装python2.7(其实2.6也行)python3不行

You can install with npm:

  1. npm install -g node-gyp

You will also need to install:

  1. On Unix:
  2. python (v2.7 recommended, v3.x.x is not supported)
  3. make
  4. A proper C/C++ compiler toolchain, like GCC
  5. On Mac OS X:
  6. You also need to install the Command Line Tools via Xcode. You can find this under the menu Xcode -> Preferences -> Downloads
  7. This step will install gcc and the related toolchain containing make
  8. python (v2.7 recommended, v3.x.x is not supported) (already installed on Mac OS X)
  9. Xcode
  10. On Windows:
  11. For 64-bit builds of node and native modules you will also need the Windows 7 64-bit SDK
  12. You may need to run one of the following commands if your build complains about WindowsSDKDir not being set, and you are sure you have already installed the SDK:
  13. Microsoft Visual Studio C++ 2013 for Windows Desktop (Express version works well)
  14. Microsoft Visual Studio C++ 2013 (Express version works well)
  15. If the install fails, try uninstalling any C++ 2010 x64&x86 Redistributable that you have installed first
  16. If you get errors that the 64-bit compilers are not installed you may also need thecompiler update for the Windows SDK 7.1
  17. Make sure that you have a PYTHON environment variable, and it is set to drive:\path\to\python.exe not to a folder
  18. Python (v2.7.3 recommended, v3.x.x is not supported)
  19. Windows XP/Vista/7:
  20. Windows 7/8:
  21. All Windows Versions
  22. call "C:\Program Files\Microsoft SDKs\Windows\v7.1\bin\Setenv.cmd" /Release /x86
  23. call "C:\Program Files\Microsoft SDKs\Windows\v7.1\bin\Setenv.cmd" /Release /x64

If you have multiple Python versions installed, you can identify which Python version node-gyp uses by setting the ‘—python’ variable:

  1. node-gyp --python /path/to/python2.7

If node-gyp is called by way of npm and you have multiple versions of Python installed, then you can set npm‘s ‘python’ config key to the appropriate value:

  1. npm config set python /path/to/executable/python2.7

Note that OS X is just a flavour of Unix and so needs python, make, and C/C++. An easy way to obtain these is to install XCode from Apple, and then use it to install the command line tools (under Preferences -> Downloads).

安装Python环境之后,还需要配置环境变量,不然报错

  1. gyp ERR! configure error
  2. gyp ERR! stack Error: Can't find Python executable "/path/to/executable/python2.7", you can set the PYTHON env variable.

watermark_type_d3F5LXplbmhlaQ_shadow_50_text_Q1NETiBATWluZ2dlUWluZ2NodW4_size_20_color_FFFFFF_t_70_g_se_x_16 1

1、下载安装Python2.7,设置环境变量 (博主安装Python路径:D:\SoftDevelopmentTools\python2.7.3)

watermark_type_d3F5LXplbmhlaQ_shadow_50_text_Q1NETiBATWluZ2dlUWluZ2NodW4_size_20_color_FFFFFF_t_70_g_se_x_16 2

2、执行命令

  1. npm config set python "D:\SoftDevelopmentTools\python2.7.3\python.exe"

3、重新执行

  1. npm install

发表评论

表情:
评论列表 (有 0 条评论,116人围观)

还没有评论,来说两句吧...

相关阅读