• 카테고리

    질문 & 답변
  • 세부 분야

    풀스택

  • 해결 여부

    미해결

detectProduct.js 오류 질문 드립니다

22.02.04 17:59 작성 조회수 286

1

다른 분들과 마찬가지로 tensorflow/tfjs-node가 깔리지 않아 난항을 겪다가 어떻게 답변하신 거 보고 따라하면서 tensorflow/tfjs-node는 깔았는데요ㅠㅠ (경로로 들어가지는 걸 보니 된 것 같습니다..) 

 

1) 

10:56초처럼 node helpers/detectProduct.js 입력했더니

C:\Users\wishd\Desktop\올인원자바\grab-market-server2>node helpers/detectProduct.js

C:\Users\wishd\Desktop\올인원자바\grab-market-server2\node_modules\@tensorflow\tfjs-node\dist\index.js:49

    throw new Error("The Node.js native addon module (tfjs_binding.node) can not " +

    ^




Error: The Node.js native addon module (tfjs_binding.node) can not be found at path: C:\Users\wishd\Desktop\올인원자 바\grab-market-server2\node_modules\@tensorflow\tfjs-node\lib\napi-v7\tfjs_binding.node.

Please run command 'npm rebuild @tensorflow/tfjs-node build-addon-from-source' to rebuild the native addon module.   

If you have problem with building the addon module, please check https://github.com/tensorflow/tfjs/blob/master/tfjs-node/WINDOWS_TROUBLESHOOTING.md or file an issue.

    at Object.<anonymous> (C:\Users\wishd\Desktop\올인원자바\grab-market-server2\node_modules\@tensorflow\tfjs-node\dist\index.js:49:11)

    at Module._compile (node:internal/modules/cjs/loader:1101:14)

    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)

    at Module.load (node:internal/modules/cjs/loader:981:32)

    at Function.Module._load (node:internal/modules/cjs/loader:822:12)

    at Module.require (node:internal/modules/cjs/loader:1005:19)

    at require (node:internal/modules/cjs/helpers:102:18)

    at Object.<anonymous> (C:\Users\wishd\Desktop\올인원자바\grab-market-server2\helpers\detectProduct.js:1:12)      

    at Module._compile (node:internal/modules/cjs/loader:1101:14)

    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)

 

이렇게 오류가 떴습니다

 

2) 위에서 시키는 것처럼 npm rebuild @tensorflow/tfjs-node build-addon-from-source를 실행한 후 다시 해봤지만 똑같은 결과가 나왔습니다

3) 
npm install -g node-gyp
node-gyp configure --verbose를 해보았는데



C:\Users\wishd\Desktop\올인원자바\grab-market-server2>npm install -g node-gyp




changed 90 packages, and audited 91 packages in 4s




4 packages are looking for funding

  run `npm fund` for details




found 0 vulnerabilities




C:\Users\wishd\Desktop\올인원자바\grab-market-server2>node-gyp configure --verbose

gyp info it worked if it ends with ok

gyp verb cli [

gyp verb cli   'C:\\Program Files\\nodejs\\node.exe',

gyp verb cli   'C:\\Users\\wishd\\AppData\\Roaming\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js',

gyp verb cli   'configure',

gyp verb cli   '--verbose'

gyp verb cli ]

gyp info using node-gyp@8.4.1

gyp info using node@16.13.1 | win32 | x64

gyp verb command configure []

gyp verb find Python Python is not set from command line or npm configuration

gyp verb find Python Python is not set from environment variable PYTHON

gyp verb find Python checking if "python3" can be used

gyp verb find Python - executing "python3" to get executable path

gyp verb find Python - "python3" is not in PATH or produced an error

gyp verb find Python checking if "python" can be used

gyp verb find Python - executing "python" to get executable path

gyp verb find Python - "python" is not in PATH or produced an error

gyp verb find Python checking if Python is C:\Users\wishd\AppData\Local\Programs\Python\Python39\python.exe

gyp verb find Python - executing "C:\Users\wishd\AppData\Local\Programs\Python\Python39\python.exe" to get version   

gyp verb find Python - "C:\Users\wishd\AppData\Local\Programs\Python\Python39\python.exe" could not be run

gyp verb find Python checking if Python is C:\Program Files\Python39\python.exe

gyp verb find Python - executing "C:\Program Files\Python39\python.exe" to get version

gyp verb find Python - "C:\Program Files\Python39\python.exe" could not be run

gyp verb find Python checking if Python is C:\Users\wishd\AppData\Local\Programs\Python\Python39-32\python.exe       

gyp verb find Python - executing "C:\Users\wishd\AppData\Local\Programs\Python\Python39-32\python.exe" to get version

gyp verb find Python - "C:\Users\wishd\AppData\Local\Programs\Python\Python39-32\python.exe" could not be run        

gyp verb find Python checking if Python is C:\Program Files\Python39-32\python.exe

gyp verb find Python - executing "C:\Program Files\Python39-32\python.exe" to get version

gyp verb find Python - "C:\Program Files\Python39-32\python.exe" could not be run

gyp verb find Python checking if Python is C:\Program Files (x86)\Python39-32\python.exe

gyp verb find Python - executing "C:\Program Files (x86)\Python39-32\python.exe" to get version

gyp verb find Python - "C:\Program Files (x86)\Python39-32\python.exe" could not be run

gyp verb find Python checking if Python is C:\Users\wishd\AppData\Local\Programs\Python\Python38\python.exe

gyp verb find Python - executing "C:\Users\wishd\AppData\Local\Programs\Python\Python38\python.exe" to get version   

gyp verb find Python - "C:\Users\wishd\AppData\Local\Programs\Python\Python38\python.exe" could not be run

gyp verb find Python checking if Python is C:\Program Files\Python38\python.exe

gyp verb find Python - executing "C:\Program Files\Python38\python.exe" to get version

gyp verb find Python - "C:\Program Files\Python38\python.exe" could not be run

gyp verb find Python checking if Python is C:\Users\wishd\AppData\Local\Programs\Python\Python38-32\python.exe       

gyp verb find Python - executing "C:\Users\wishd\AppData\Local\Programs\Python\Python38-32\python.exe" to get version

gyp verb find Python - "C:\Users\wishd\AppData\Local\Programs\Python\Python38-32\python.exe" could not be run

gyp verb find Python checking if Python is C:\Program Files\Python38-32\python.exe

gyp verb find Python - executing "C:\Program Files\Python38-32\python.exe" to get version

gyp verb find Python - "C:\Program Files\Python38-32\python.exe" could not be run

gyp verb find Python checking if Python is C:\Program Files (x86)\Python38-32\python.exe

gyp verb find Python - executing "C:\Program Files (x86)\Python38-32\python.exe" to get version

gyp verb find Python - "C:\Program Files (x86)\Python38-32\python.exe" could not be run

gyp verb find Python checking if Python is C:\Users\wishd\AppData\Local\Programs\Python\Python37\python.exe

gyp verb find Python - executing "C:\Users\wishd\AppData\Local\Programs\Python\Python37\python.exe" to get version

gyp verb find Python - "C:\Users\wishd\AppData\Local\Programs\Python\Python37\python.exe" could not be run

gyp verb find Python checking if Python is C:\Program Files\Python37\python.exe

gyp verb find Python - executing "C:\Program Files\Python37\python.exe" to get version

gyp verb find Python - "C:\Program Files\Python37\python.exe" could not be run

gyp verb find Python checking if Python is C:\Users\wishd\AppData\Local\Programs\Python\Python37-32\python.exe       

gyp verb find Python - executing "C:\Users\wishd\AppData\Local\Programs\Python\Python37-32\python.exe" to get version

gyp verb find Python - "C:\Users\wishd\AppData\Local\Programs\Python\Python37-32\python.exe" could not be run        

gyp verb find Python checking if Python is C:\Program Files\Python37-32\python.exe

gyp verb find Python - executing "C:\Program Files\Python37-32\python.exe" to get version

gyp verb find Python - "C:\Program Files\Python37-32\python.exe" could not be run

gyp verb find Python checking if Python is C:\Program Files (x86)\Python37-32\python.exe

gyp verb find Python - executing "C:\Program Files (x86)\Python37-32\python.exe" to get version

gyp verb find Python - "C:\Program Files (x86)\Python37-32\python.exe" could not be run

gyp verb find Python checking if Python is C:\Users\wishd\AppData\Local\Programs\Python\Python36\python.exe

gyp verb find Python - executing "C:\Users\wishd\AppData\Local\Programs\Python\Python36\python.exe" to get version   

gyp verb find Python - "C:\Users\wishd\AppData\Local\Programs\Python\Python36\python.exe" could not be run

gyp verb find Python checking if Python is C:\Program Files\Python36\python.exe

gyp verb find Python - executing "C:\Program Files\Python36\python.exe" to get version

gyp verb find Python - "C:\Program Files\Python36\python.exe" could not be run

gyp verb find Python checking if Python is C:\Users\wishd\AppData\Local\Programs\Python\Python36-32\python.exe       

gyp verb find Python - executing "C:\Users\wishd\AppData\Local\Programs\Python\Python36-32\python.exe" to get version

gyp verb find Python - "C:\Users\wishd\AppData\Local\Programs\Python\Python36-32\python.exe" could not be run        

gyp verb find Python checking if Python is C:\Program Files\Python36-32\python.exe

gyp verb find Python - executing "C:\Program Files\Python36-32\python.exe" to get version

gyp verb find Python - "C:\Program Files\Python36-32\python.exe" could not be run

gyp verb find Python checking if Python is C:\Program Files (x86)\Python36-32\python.exe

gyp verb find Python - executing "C:\Program Files (x86)\Python36-32\python.exe" to get version

gyp verb find Python - "C:\Program Files (x86)\Python36-32\python.exe" could not be run

gyp verb find Python checking if the py launcher can be used to find Python 3

gyp verb find Python - executing "py.exe" to get Python 3 executable path

gyp verb find Python - executable path is "C:\Users\wishd\AppData\Local\Programs\Python\Python310\python.exe"

gyp verb find Python - executing "C:\Users\wishd\AppData\Local\Programs\Python\Python310\python.exe" to get version  

gyp verb find Python - version is "3.10.2"

gyp info find Python using Python version 3.10.2 found at "C:\Users\wishd\AppData\Local\Programs\Python\Python310\python.exe"

gyp verb get node dir no --target version specified, falling back to host node version: 16.13.1

gyp verb command install [ '16.13.1' ]

gyp verb install input version string "16.13.1"

gyp verb install installing version: 16.13.1

gyp verb install --ensure was passed, so won't reinstall if already installed

gyp verb install version is already installed, need to check "installVersion"

gyp verb got "installVersion" 9

gyp verb needs "installVersion" 9

gyp verb install version is good

gyp verb get node dir target node version installed: 16.13.1

gyp verb build dir attempting to create "build" dir: C:\Users\wishd\Desktop\올인원자바\grab-market-server2\build     

gyp verb build dir "build" dir needed to be created? No

gyp verb find VS msvs_version not set from command line or npm config

gyp verb find VS VCINSTALLDIR not set, not running in VS Command Prompt

gyp verb find VS could not use PowerShell to find Visual Studio 2017 or newer, try re-running with '--loglevel silly' for more details

gyp verb find VS looking for Visual Studio 2015

gyp verb find VS - not found

gyp verb find VS not looking for VS2013 as it is only supported up to Node.js 8

gyp ERR! find VS

gyp ERR! find VS msvs_version not set from command line or npm config

gyp ERR! find VS VCINSTALLDIR not set, not running in VS Command Prompt

gyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer, try re-running with '--loglevel silly' for more details

gyp ERR! find VS looking for Visual Studio 2015

gyp ERR! find VS - not found

gyp ERR! find VS not looking for VS2013 as it is only supported up to Node.js 8

gyp ERR! find VS

gyp ERR! find VS **************************************************************

gyp ERR! find VS You need to install the latest version of Visual Studio

gyp ERR! find VS including the "Desktop development with C++" workload.

gyp ERR! find VS For more information consult the documentation at:

gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows

gyp ERR! find VS **************************************************************

gyp ERR! find VS

gyp ERR! configure error

gyp ERR! stack Error: Could not find any Visual Studio installation to use

gyp ERR! stack     at VisualStudioFinder.fail (C:\Users\wishd\AppData\Roaming\npm\node_modules\node-gyp\lib\find-visualstudio.js:122:47)

gyp ERR! stack     at C:\Users\wishd\AppData\Roaming\npm\node_modules\node-gyp\lib\find-visualstudio.js:75:16        

gyp ERR! stack     at VisualStudioFinder.findVisualStudio2013 (C:\Users\wishd\AppData\Roaming\npm\node_modules\node-gyp\lib\find-visualstudio.js:363:14)

gyp ERR! stack     at C:\Users\wishd\AppData\Roaming\npm\node_modules\node-gyp\lib\find-visualstudio.js:71:14        

gyp ERR! stack     at C:\Users\wishd\AppData\Roaming\npm\node_modules\node-gyp\lib\find-visualstudio.js:384:16       

gyp ERR! stack     at C:\Users\wishd\AppData\Roaming\npm\node_modules\node-gyp\lib\util.js:54:7

gyp ERR! stack     at C:\Users\wishd\AppData\Roaming\npm\node_modules\node-gyp\lib\util.js:33:16

gyp ERR! stack     at ChildProcess.exithandler (node:child_process:404:5)

gyp ERR! stack     at ChildProcess.emit (node:events:390:28)

gyp ERR! stack     at maybeClose (node:internal/child_process:1064:16)

gyp ERR! System Windows_NT 10.0.22000

gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\wishd\\AppData\\Roaming\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "configure" "--verbose"

gyp ERR! cwd C:\Users\wishd\Desktop\올인원자바\grab-market-server2

gyp ERR! node -v v16.13.1

gyp ERR! node-gyp -v v8.4.1

gyp ERR! not ok

 

이러한 오류가 떴고,
이후의 node helpers/detectProduct.js 결과는 위와 똑같이 오류가 났습니다.

 

 

4) 이후에 검색해보다가 npm i -g node-pre-gyp를 실행한 뒤 npm rebuild @tensorflow/tfjs-node build-addon-from-source를 실행해 해결할 수 있다는 말을 보고 해보았는데, 


C:\Users\wishd\Desktop\올인원자바\grab-market-server2>npm i -g node-pre-gyp

npm WARN deprecated node-pre-gyp@0.17.0: Please upgrade to @mapbox/node-pre-gyp: the non-scoped node-pre-gyp package is deprecated and only the @mapbox scoped package will recieve updates in the future


added 67 packages, and audited 68 packages in 5s


2 packages are looking for funding

  run `npm fund` for details


found 0 vulnerabilities


C:\Users\wishd\Desktop\올인원자바\grab-market-server2>npm rebuild @tensorflow/tfjs-node build-addon-from-source

rebuilt dependencies successfully

이처럼 잘 된 것 같았는데..

 

5) 다시 node helpers/detectProduct.js 실행하니까 이번에는

C:\Users\wishd\Desktop\올인원자바\grab-market-server2>node helpers/detectProduct.js

node:internal/modules/cjs/loader:1183

  return process.dlopen(module, path.toNamespacedPath(filename));

                 ^

ì°ror: The specified module could not be found.

  \\?\C:\Users\wishd\Desktop\ì\grab-market-server2\node_modules\@tensorflow\tfjs-node\lib\napi-v7\tfjs_binding.node    

    at Object.Module._extensions..node (node:internal/modules/cjs/loader:1183:18)

    at Module.load (node:internal/modules/cjs/loader:981:32)

    at Function.Module._load (node:internal/modules/cjs/loader:822:12)

    at Module.require (node:internal/modules/cjs/loader:1005:19)

    at require (node:internal/modules/cjs/helpers:102:18)

    at Object.<anonymous> (C:\Users\wishd\Desktop\올인원자바\grab-market-server2\node_modules\@tensorflow\tfjs-node\dist\index.js:58:16)

    at Module._compile (node:internal/modules/cjs/loader:1101:14)

    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)

    at Module.load (node:internal/modules/cjs/loader:981:32)

    at Function.Module._load (node:internal/modules/cjs/loader:822:12) {

  code: 'ERR_DLOPEN_FAILED'

}

이렇게 또 다른 오류가 나네요 ㅠㅠ

 

 

 

 

 

혼자 더 찾아서 아무거나 넣어보다가 더 잘못되는 게 아닌가 싶어서 질문 남깁니다..ㅠ 

운영체제는 윈도우고 detectProduct.js 내의 코드는

const tf = require("@tensorflow/tfjs-node");
const mobilenet = require("@tensorflow-models/mobilenet");
const fs = require("fs");
const path = require("path");

function detectProduct(url) {
  const image = fs.readFileSync(url);
  const input = tf.node.decodeImage(image, 3);
  console.log(input);
}

detectProduct(path.join(__dirname, "../uploads/notebook1.jpg"));

위와 같습니다. 도움 부탁드려요  
참고로 파이썬 2.7은 같은 C:/안에 설치되어있어요.. 

답변 2

·

답변을 작성해보세요.

0

박재석님의 프로필

박재석

2022.02.12

저도 같은 이유로 실행이 안되었었는데 tfjs-node 문제였습니다. 

npm uninstall --save @tensorflow/tfjs-node 후에

npm install --save @tensorflow/tfjs-node@3.13.0 적용 후 실행되었습니다.

0

확인이 늦어서 죄송합니다!

윈도우에서 컴퓨터 별로 환경이 다르다보니 오류가 참 다양하군요 😅

 

rm -rf node_modules를 통해 node_modules 폴더를 전부 지우고 npm install 로 다시 설치해서 진행해보시겠어요?!