服务器npm i 找不到python错误
npm ERR! code 1
npm ERR! path /home/yangzhixiang/console-vue/node_modules/node-sass
npm ERR! command failed
npm ERR! command sh -c node scripts/build.js
npm ERR! Building: /www/server/nodejs/v16.9.0/bin/node /home/yangzhixiang/console-vue/node_modules/node-gyp/bin/node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp verb cli [
npm ERR! gyp verb cli '/www/server/nodejs/v16.9.0/bin/node',
npm ERR! gyp verb cli '/home/yangzhixiang/console-vue/node_modules/node-gyp/bin/node-gyp.js',
npm ERR! gyp verb cli 'rebuild',
npm ERR! gyp verb cli '--verbose',
npm ERR! gyp verb cli '--libsass_ext=',
npm ERR! gyp verb cli '--libsass_cflags=',
npm ERR! gyp verb cli '--libsass_ldflags=',
npm ERR! gyp verb cli '--libsass_library='
npm ERR! gyp verb cli ]
npm ERR! gyp info using node-gyp@8.4.1
npm ERR! gyp info using node@16.9.0 | linux | x64
npm ERR! gyp verb command rebuild []
npm ERR! gyp verb command clean []
npm ERR! gyp verb clean removing "build" directory
npm ERR! gyp verb command configure []
npm ERR! gyp verb find Python Python is not set from command line or npm configuration
npm ERR! gyp verb find Python Python is not set from environment variable PYTHON
npm ERR! gyp verb find Python checking if "python3" can be used
npm ERR! gyp verb find Python - executing "python3" to get executable path
npm ERR! gyp verb find Python - "python3" is not in PATH or produced an error
npm ERR! gyp verb find Python checking if "python" can be used
npm ERR! gyp verb find Python - executing "python" to get executable path
npm ERR! gyp verb find Python - executable path is "/bin/python"
npm ERR! gyp verb find Python - executing "/bin/python" to get version
npm ERR! gyp verb find Python - version is "2.7.5"
npm ERR! gyp verb find Python - version is 2.7.5 - should be >=3.6.0
npm ERR! gyp verb find Python - THIS VERSION OF PYTHON IS NOT SUPPORTED
npm ERR! gyp ERR! find Python
npm ERR! gyp ERR! find Python Python is not set from command line or npm configuration
npm ERR! gyp ERR! find Python Python is not set from environment variable PYTHON
npm ERR! gyp ERR! find Python checking if "python3" can be used
npm ERR! gyp ERR! find Python - "python3" is not in PATH or produced an error
npm ERR! gyp ERR! find Python checking if "python" can be used
npm ERR! gyp ERR! find Python - executable path is "/bin/python"
npm ERR! gyp ERR! find Python - version is "2.7.5"
npm ERR! gyp ERR! find Python - version is 2.7.5 - should be >=3.6.0
npm ERR! gyp ERR! find Python - THIS VERSION OF PYTHON IS NOT SUPPORTED
npm ERR! gyp ERR! find Python
npm ERR! gyp ERR! find Python **********************************************************
npm ERR! gyp ERR! find Python You need to install the latest version of Python.
npm ERR! gyp ERR! find Python Node-gyp should be able to find and use Python. If not,
npm ERR! gyp ERR! find Python you can try one of the following options:
npm ERR! gyp ERR! find Python - Use the switch --python="/path/to/pythonexecutable"
npm ERR! gyp ERR! find Python (accepted by both node-gyp and npm)
npm ERR! gyp ERR! find Python - Set the environment variable PYTHON
npm ERR! gyp ERR! find Python - Set the npm configuration variable python:
npm ERR! gyp ERR! find Python npm config set python "/path/to/pythonexecutable"
npm ERR! gyp ERR! find Python For more information consult the documentation at:
npm ERR! gyp ERR! find Python https://github.com/nodejs/node-gyp#installation
npm ERR! gyp ERR! find Python **********************************************************
npm ERR! gyp ERR! find Python
npm ERR! gyp ERR! configure error
npm ERR! gyp ERR! stack Error: Could not find any Python installation to use
npm ERR! gyp ERR! stack at PythonFinder.fail (/home/yangzhixiang/console-vue/node_modules/node-gyp/lib/find-python.js:330:47)
npm ERR! gyp ERR! stack at PythonFinder.runChecks (/home/yangzhixiang/console-vue/node_modules/node-gyp/lib/find-python.js:159:21)
npm ERR! gyp ERR! stack at PythonFinder.<anonymous> (/home/yangzhixiang/console-vue/node_modules/node-gyp/lib/find-python.js:266:16)
npm ERR! gyp ERR! stack at PythonFinder.execFileCallback (/home/yangzhixiang/console-vue/node_modules/node-gyp/lib/find-python.js:297:7)
npm ERR! gyp ERR! stack at ChildProcess.exithandler (node:child_process:388:7)
npm ERR! gyp ERR! stack at ChildProcess.emit (node:events:394:28)
npm ERR! gyp ERR! stack at maybeClose (node:internal/child_process:1064:16)
npm ERR! gyp ERR! stack at Process.ChildProcess._handle.onexit (node:internal/child_process:301:5)
npm ERR! gyp ERR! System Linux 3.10.0-1160.88.1.el7.x86_64
npm ERR! gyp ERR! command "/www/server/nodejs/v16.9.0/bin/node" "/home/yangzhixiang/console-vue/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
npm ERR! gyp ERR! cwd /home/yangzhixiang/console-vue/node_modules/node-sass
npm ERR! gyp ERR! node -v v16.9.0
npm ERR! gyp ERR! node-gyp -v v8.4.1
npm ERR! gyp ERR! not ok
npm ERR! Build failed with error code: 1
npm ERR! A complete log of this run can be found in:
npm ERR! /www/server/nodejs/v16.9.0/cache/_logs/2024-04-24T07_26_48_260Z-debug.log
安装python
查看linux默认安装的python位置
软连接指向 python2 、python2.7,以上python3是后面加的。
下载python.tgz
https://www.python.org/downloads/source/
mkdir /usr/local/python3
cd /usr/local/python3
wget https://www.python.org/ftp/python/3.7.16/Python-3.7.16.tgztar -zxvf Python-3.7.16.tgz
准备编译环境
yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make编译安装
cd /usr/local/python3/Python-3.7.16./configure --prefix=/usr/local/python3/Python-3.7.16 make make install
创建软连接
ln -s /usr/local/python3/Python-3.7.16 /bin/python3配置环境变量
vi /etc/profile#配置python export PYTHON_HOME=/usr/local/python3/Python-3.7.16 export PATH=$PYTHON_HOME/bin:$PATH
vi ~/.bashrc
source /etc/profile
source /etc/profile
source ~/.bashrc
参考网址:Linux系统安装Python3环境(超详细) - 知乎 (zhihu.com)
npm 设置python
npm config set python "/usr/local/python3/Python-3.7.16"
参考网址:npm install - gyp ERR! find Python 解决方案 - kaisheng_reflect - 博客园 (cnblogs.com)