npm install python error 해결하기 대작전.

wonjun.Aden·2022년 9월 23일
1
post-thumbnail

후....window에서는 잘되던 docker image build가 mac에서 갑자기 되지 않았다.


python error라고 하는데 처음 보는 에러였다. 좀 찾아보니 docker node alpine 버전을 사용하려고 할 때 자주 발생하는 것 같았다. mac 환경에서도 잘 일어날 수 있을 것이라 생각한다.
암튼 간단하지만 빡치는 에러를 해결하는 방법을 공유해본다.

 > [6/7] RUN npm install:                                             
#10 34.79 npm WARN deprecated multibase@0.6.1: This module has been superseded by the multiformats module                                 #10 34.83 npm WARN deprecated multicodec@0.5.7: This module has been superseded by the multiformats module
#10 34.88 npm WARN deprecated mkdirp-promise@5.0.1: This package is broken and no longer maintained. 'mkdirp' itself supports promises now, please switch to that.
#10 35.33 npm WARN deprecated har-validator@5.1.5: this library is no longer supported
#10 35.48 npm WARN deprecated uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
#10 35.80 npm WARN deprecated @hapi/pinpoint@2.0.0: Moved to 'npm install @sideway/pinpoint'
#10 35.86 npm WARN deprecated @hapi/address@4.1.0: Moved to 'npm install @sideway/address'
#10 36.17 npm WARN deprecated @hapi/formula@2.0.0: Moved to 'npm install @sideway/formula'
#10 36.48 npm WARN deprecated multicodec@1.0.4: This module has been superseded by the multiformats module
#10 36.49 npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
#10 36.51 npm WARN deprecated uuid@3.3.2: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
#10 36.57 npm WARN deprecated multibase@0.7.0: This module has been superseded by the multiformats module
#10 36.60 npm WARN deprecated cids@0.7.5: This module has been superseded by the multiformats module
#10 36.62 npm WARN deprecated @hapi/joi@17.1.1: Switch to 'npm install joi'
#10 36.65 npm WARN deprecated axios@0.19.2: Critical security vulnerability fixed in v0.21.1. For more information, see https://github.com/axios/axios/pull/3410
#10 37.87 npm ERR! code 1
#10 37.87 npm ERR! path /usr/src/app/node_modules/bufferutil
#10 37.87 npm ERR! command failed
#10 37.87 npm ERR! command sh /tmp/install-45527d99.sh
#10 37.87 npm ERR! gyp info it worked if it ends with ok
#10 37.87 npm ERR! gyp info using node-gyp@9.0.0
#10 37.87 npm ERR! gyp info using node@16.17.0 | linux | arm64
#10 37.87 npm ERR! gyp ERR! find Python 
#10 37.87 npm ERR! gyp ERR! find Python Python is not set from command line or npm configuration
#10 37.87 npm ERR! gyp ERR! find Python Python is not set from environment variable PYTHON
#10 37.87 npm ERR! gyp ERR! find Python checking if "python3" can be used
#10 37.87 npm ERR! gyp ERR! find Python - "python3" is not in PATH or produced an error
#10 37.87 npm ERR! gyp ERR! find Python checking if "python" can be used
#10 37.87 npm ERR! gyp ERR! find Python - "python" is not in PATH or produced an error
#10 37.87 npm ERR! gyp ERR! find Python 
#10 37.87 npm ERR! gyp ERR! find Python **********************************************************
#10 37.87 npm ERR! gyp ERR! find Python You need to install the latest version of Python.
#10 37.87 npm ERR! gyp ERR! find Python Node-gyp should be able to find and use Python. If not,
#10 37.87 npm ERR! gyp ERR! find Python you can try one of the following options:
#10 37.87 npm ERR! gyp ERR! find Python - Use the switch --python="/path/to/pythonexecutable"
#10 37.87 npm ERR! gyp ERR! find Python   (accepted by both node-gyp and npm)
#10 37.87 npm ERR! gyp ERR! find Python - Set the environment variable PYTHON
#10 37.87 npm ERR! gyp ERR! find Python - Set the npm configuration variable python:
#10 37.87 npm ERR! gyp ERR! find Python   npm config set python "/path/to/pythonexecutable"
#10 37.87 npm ERR! gyp ERR! find Python For more information consult the documentation at:
#10 37.87 npm ERR! gyp ERR! find Python https://github.com/nodejs/node-gyp#installation
#10 37.87 npm ERR! gyp ERR! find Python **********************************************************
#10 37.87 npm ERR! gyp ERR! find Python 
#10 37.87 npm ERR! gyp ERR! configure error 
#10 37.87 npm ERR! gyp ERR! stack Error: Could not find any Python installation to use
#10 37.87 npm ERR! gyp ERR! stack     at PythonFinder.fail (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/find-python.js:330:47)
#10 37.87 npm ERR! gyp ERR! stack     at PythonFinder.runChecks (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/find-python.js:159:21)
#10 37.87 npm ERR! gyp ERR! stack     at PythonFinder.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/find-python.js:202:16)
#10 37.87 npm ERR! gyp ERR! stack     at PythonFinder.execFileCallback (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/find-python.js:294:16)
#10 37.87 npm ERR! gyp ERR! stack     at exithandler (node:child_process:408:5)
#10 37.87 npm ERR! gyp ERR! stack     at ChildProcess.errorhandler (node:child_process:420:5)
#10 37.87 npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:513:28)
#10 37.87 npm ERR! gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:289:12)
#10 37.87 npm ERR! gyp ERR! stack     at onErrorNT (node:internal/child_process:478:16)
#10 37.87 npm ERR! gyp ERR! stack     at processTicksAndRejections (node:internal/process/task_queues:83:21)
#10 37.87 npm ERR! gyp ERR! System Linux 5.10.104-linuxkit
#10 37.87 npm ERR! gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
#10 37.87 npm ERR! gyp ERR! cwd /usr/src/app/node_modules/bufferutil
#10 37.87 npm ERR! gyp ERR! node -v v16.17.0
#10 37.87 npm ERR! gyp ERR! node-gyp -v v9.0.0
#10 37.87 npm ERR! gyp ERR! not ok
#10 37.87 
#10 37.87 npm ERR! A complete log of this run can be found in:
#10 37.87 npm ERR!     /root/.npm/_logs/2022-09-23T06_07_33_937Z-debug-0.log

이런 에러가 발생하였었다.
이걸 어떻게 하면 해결할 수 있는가 찾아봤는데

apk add --update python3 make g++ && rm -rf /var/cache/apk/*

이 명령어를 입력하기만 하면 되던 것이었다..

물론 Dockerfile 만들땐 RUN 붙혀서 docker 이미지 빌드하면 된다.

profile
아프리카의 BackEnd Developer 장원준입니다.

0개의 댓글