首页 新闻 会员 周边 捐助

npm 安装 deasync 报错"Could not find any Python installation to use"

0
悬赏园豆:30 [已解决问题] 解决于 2022-02-22 16:21

使用 node:lts-alpine 镜像 build angular 前端项目在执行 npm ci 时报错,请问如何解决?

> [build-node 11/22] RUN npm ci:                                                                                                                                       
#30 31.42 npm ERR! code 1                                                                                                                                               
#30 31.42 npm ERR! path /src/src/Cnblogs.Admin.Web/wwwroot/node_modules/deasync                                                                                      
#30 31.43 npm ERR! command failed                                                                                                                                       
#30 31.43 npm ERR! command sh -c node ./build.js                                                                                                                        
#30 31.43 npm ERR! gyp info it worked if it ends with ok                                                                                                                
#30 31.43 npm ERR! gyp info using node-gyp@8.3.0                                                                                                                        
#30 31.43 npm ERR! gyp info using node@16.13.1 | linux | x64                                                                                                            
#30 31.43 npm ERR! gyp ERR! find Python 
#30 31.43 npm ERR! gyp ERR! find Python Python is not set from command line or npm configuration
#30 31.43 npm ERR! gyp ERR! find Python Python is not set from environment variable PYTHON
#30 31.43 npm ERR! gyp ERR! find Python checking if "python3" can be used
#30 31.43 npm ERR! gyp ERR! find Python - "python3" is not in PATH or produced an error
#30 31.43 npm ERR! gyp ERR! find Python checking if "python" can be used
#30 31.43 npm ERR! gyp ERR! find Python - "python" is not in PATH or produced an error
#30 31.43 npm ERR! gyp ERR! find Python 
#30 31.43 npm ERR! gyp ERR! find Python **********************************************************
#30 31.43 npm ERR! gyp ERR! find Python You need to install the latest version of Python.
#30 31.43 npm ERR! gyp ERR! find Python Node-gyp should be able to find and use Python. If not,
#30 31.43 npm ERR! gyp ERR! find Python you can try one of the following options:
#30 31.43 npm ERR! gyp ERR! find Python - Use the switch --python="/path/to/pythonexecutable"
#30 31.43 npm ERR! gyp ERR! find Python   (accepted by both node-gyp and npm)
#30 31.43 npm ERR! gyp ERR! find Python - Set the environment variable PYTHON
#30 31.43 npm ERR! gyp ERR! find Python - Set the npm configuration variable python:
#30 31.43 npm ERR! gyp ERR! find Python   npm config set python "/path/to/pythonexecutable"
#30 31.43 npm ERR! gyp ERR! find Python For more information consult the documentation at:
#30 31.43 npm ERR! gyp ERR! find Python https://github.com/nodejs/node-gyp#installation
#30 31.43 npm ERR! gyp ERR! find Python **********************************************************
#30 31.43 npm ERR! gyp ERR! find Python 
#30 31.43 npm ERR! gyp ERR! configure error 
#30 31.43 npm ERR! gyp ERR! stack Error: Could not find any Python installation to use
#30 31.43 npm ERR! gyp ERR! stack     at PythonFinder.fail (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/find-python.js:330:47)
#30 31.43 npm ERR! gyp ERR! stack     at PythonFinder.runChecks (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/find-python.js:159:21)
#30 31.43 npm ERR! gyp ERR! stack     at PythonFinder.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/find-python.js:202:16)
#30 31.43 npm ERR! gyp ERR! stack     at PythonFinder.execFileCallback (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/find-python.js:294:16)
#30 31.43 npm ERR! gyp ERR! stack     at exithandler (node:child_process:404:5)
#30 31.43 npm ERR! gyp ERR! stack     at ChildProcess.errorhandler (node:child_process:416:5)
#30 31.43 npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:390:28)
#30 31.43 npm ERR! gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:288:12)
#30 31.43 npm ERR! gyp ERR! stack     at onErrorNT (node:internal/child_process:477:16)
#30 31.43 npm ERR! gyp ERR! stack     at processTicksAndRejections (node:internal/process/task_queues:83:21)
#30 31.43 npm ERR! gyp ERR! System Linux 4.4.0-117-generic
#30 31.43 npm ERR! gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
#30 31.43 npm ERR! gyp ERR! cwd /src/src/Cnblogs.Admin.Web/wwwroot/node_modules/deasync
#30 31.43 npm ERR! gyp ERR! node -v v16.13.1
#30 31.43 npm ERR! gyp ERR! node-gyp -v v8.3.0
#30 31.43 npm ERR! gyp ERR! not ok 
#30 31.43 npm ERR! Build failed
npm
问题补充:

node 镜像改为 node:lts-alpine3.10 就不会出现问题

dudu的主页 dudu | 高人七级 | 园豆:30948
提问于:2022-01-21 17:43
< >
分享
最佳答案
0

RUN apk --no-cache add --virtual .builds-deps build-base python3

收获园豆:30
Laggage | 小虾三级 |园豆:878 | 2022-02-22 11:32

使用这个命令成功安装 python3 ,使用国内源安装会快很多

RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
RUN apk --no-cache add --virtual .builds-deps build-base python3
dudu | 园豆:30948 (高人七级) | 2022-02-22 14:30

现在出现新的错误

#33 29.22 npm ERR! code 1                                                                                                                                                                                   
#33 29.22 npm ERR! path /src/src/BlogServer.Admin.Web/wwwroot/node_modules/deasync                                                                                                                          
#33 29.22 npm ERR! command failed                                                                                                                                                                           
#33 29.22 npm ERR! command sh -c node ./build.js                                                                                                                                                            
#33 29.22 npm ERR! make: Entering directory '/src/src/BlogServer.Admin.Web/wwwroot/node_modules/deasync/build'                                                                                              
#33 29.22 npm ERR! make: Leaving directory '/src/src/BlogServer.Admin.Web/wwwroot/node_modules/deasync/build'
#33 29.22 npm ERR! gyp info it worked if it ends with ok
...
#33 29.22 npm ERR! gyp info spawn /usr/bin/python3
...
#33 29.22 npm ERR! gyp info spawn make
#33 29.22 npm ERR! gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
#33 29.22 npm ERR! make: printf: Operation not permitted
#33 29.22 npm ERR! make: *** [deasync.target.mk:111: Release/obj.target/deasync/src/deasync.o] Error 127
#33 29.22 npm ERR! gyp ERR! build error 
#33 29.22 npm ERR! gyp ERR! stack Error: `make` failed with exit code: 2
#33 29.22 npm ERR! gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
#33 29.22 npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:390:28)
#33 29.22 npm ERR! gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:290:12)
#33 29.22 npm ERR! gyp ERR! System Linux 4.4.0-117-generic
#33 29.22 npm ERR! gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
#33 29.22 npm ERR! gyp ERR! cwd /src/src/BlogServer.Admin.Web/wwwroot/node_modules/deasync
#33 29.22 npm ERR! gyp ERR! node -v v16.13.1
#33 29.22 npm ERR! gyp ERR! node-gyp -v v8.3.0
#33 29.22 npm ERR! gyp ERR! not ok 
#33 29.22 npm ERR! Build failed
dudu | 园豆:30948 (高人七级) | 2022-02-22 14:35

@dudu:

33 29.22 npm ERR! make: printf: Operation not permitted

可以试试docker build时加上--no-cache

Laggage | 园豆:878 (小虾三级) | 2022-02-22 15:17

@Laggage: 把 docker 从 19.03.4 升级至 20.10.7 解决了,

dudu | 园豆:30948 (高人七级) | 2022-02-22 16:21
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册