BrainJS / brain.js

🤖 GPU accelerated Neural networks in JavaScript for Browsers and Node.js
https://brain.js.org
MIT License
14.25k stars 1.06k forks source link

Unable to install Brain.js on PopOS #904

Open kul-sudo opened 11 months ago

kul-sudo commented 11 months ago

A GIF or MEME to give some spice of the internet

What is wrong?

When I run npm i brain.js in the folder of my project, I get the following error:

npm ERR! code 1
npm ERR! path /home/user/Documents/chessy/node_modules/gl
npm ERR! command failed
npm ERR! command sh -c prebuild-install || node-gyp rebuild
npm ERR! prebuild-install warn install No prebuilt binaries found (target=20.5.0 runtime=node arch=x64 libc= platform=linux)
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@9.4.0
npm ERR! gyp info using node@20.5.0 | linux | x64
npm ERR! gyp info find Python using Python version 3.11.4 found at "/home/linuxbrew/.linuxbrew/opt/python@3.11/bin/python3.11"
npm ERR! gyp info spawn /home/linuxbrew/.linuxbrew/opt/python@3.11/bin/python3.11
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args   '/home/user/Documents/chessy/node_modules/node-gyp/gyp/gyp_main.py',
npm ERR! gyp info spawn args   'binding.gyp',
npm ERR! gyp info spawn args   '-f',
npm ERR! gyp info spawn args   'make',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/home/user/Documents/chessy/node_modules/gl/build/config.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/home/user/Documents/chessy/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/home/user/.cache/node-gyp/20.5.0/include/node/common.gypi',
npm ERR! gyp info spawn args   '-Dlibrary=shared_library',
npm ERR! gyp info spawn args   '-Dvisibility=default',
npm ERR! gyp info spawn args   '-Dnode_root_dir=/home/user/.cache/node-gyp/20.5.0',
npm ERR! gyp info spawn args   '-Dnode_gyp_dir=/home/user/Documents/chessy/node_modules/node-gyp',
npm ERR! gyp info spawn args   '-Dnode_lib_file=/home/user/.cache/node-gyp/20.5.0/<(target_arch)/node.lib',
npm ERR! gyp info spawn args   '-Dmodule_root_dir=/home/user/Documents/chessy/node_modules/gl',
npm ERR! gyp info spawn args   '-Dnode_engine=v8',
npm ERR! gyp info spawn args   '--depth=.',
npm ERR! gyp info spawn args   '--no-parallel',
npm ERR! gyp info spawn args   '--generator-output',
npm ERR! gyp info spawn args   'build',
npm ERR! gyp info spawn args   '-Goutput_dir=.'
npm ERR! gyp info spawn args ]
npm ERR! /bin/sh: 1: python: not found
npm ERR! gyp: Call to 'python commit_id.py check ..' returned exit status 127 while in angle/src/angle.gyp. while loading dependencies of binding.gyp while trying to load binding.gyp
npm ERR! gyp ERR! configure error 
npm ERR! gyp ERR! stack Error: `gyp` failed with exit code: 1
npm ERR! gyp ERR! stack     at ChildProcess.onCpExit (/home/user/Documents/chessy/node_modules/node-gyp/lib/configure.js:325:16)
npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:514:28)
npm ERR! gyp ERR! stack     at ChildProcess._handle.onexit (node:internal/child_process:294:12)
npm ERR! gyp ERR! System Linux 6.2.6-76060206-generic
npm ERR! gyp ERR! command "/home/linuxbrew/.linuxbrew/Cellar/node/20.5.0/bin/node" "/home/user/Documents/chessy/node_modules/.bin/node-gyp" "rebuild"
npm ERR! gyp ERR! cwd /home/user/Documents/chessy/node_modules/gl
npm ERR! gyp ERR! node -v v20.5.0
npm ERR! gyp ERR! node-gyp -v v9.4.0
npm ERR! gyp ERR! not ok

Whenever I try to sort of omit this error and do yarn add brain.js, I run the app and get the message Error: Cannot find module 'gpu.js'.

I use Brain.js in Next.js.

Version information

Nodejs:

v20.5.0

Browser:

Google Chrome

Brain.js:

Unable to install, but mean to install the latest version possible.

How important is this (1-5)?

It, I think, is 5, because I cannot install the library from the very get-go.

Other Comments

I never have this error on Windows.

kul-sudo commented 11 months ago

I also have noticed that many people have created similar issues, but none of them has got a clear solution that works.

seunafara commented 11 months ago

Your error message - Error: Cannot find module 'gpu.js' - means you have to also do npm install gpu.js

kul-sudo commented 11 months ago

Your error message - Error: Cannot find module 'gpu.js' - means you have to also do npm install gpu.js

I wish it was as simple as that.

It shows the following error when I do yarn add gpu.js:

error /home/user/Documents/chessy/node_modules/gl: Command failed.
Exit code: 1
Command: prebuild-install || node-gyp rebuild
Arguments: 
Directory: /home/user/Documents/chessy/node_modules/gl
Output:
prebuild-install warn install No prebuilt binaries found (target=20.5.0 runtime=node arch=x64 libc= platform=linux)
gyp info it worked if it ends with ok
gyp info using node-gyp@9.4.0
gyp info using node@20.5.0 | linux | x64
gyp info find Python using Python version 3.10.6 found at "/usr/bin/python3"
gyp info spawn /usr/bin/python3
gyp info spawn args [
gyp info spawn args   '/home/user/Documents/chessy/node_modules/node-gyp/gyp/gyp_main.py',
gyp info spawn args   'binding.gyp',
gyp info spawn args   '-f',
gyp info spawn args   'make',
gyp info spawn args   '-I',
gyp info spawn args   '/home/user/Documents/chessy/node_modules/gl/build/config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/home/user/Documents/chessy/node_modules/node-gyp/addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/home/user/.cache/node-gyp/20.5.0/include/node/common.gypi',
gyp info spawn args   '-Dlibrary=shared_library',
gyp info spawn args   '-Dvisibility=default',
gyp info spawn args   '-Dnode_root_dir=/home/user/.cache/node-gyp/20.5.0',
gyp info spawn args   '-Dnode_gyp_dir=/home/user/Documents/chessy/node_modules/node-gyp',
gyp info spawn args   '-Dnode_lib_file=/home/user/.cache/node-gyp/20.5.0/<(target_arch)/node.lib',
gyp info spawn args   '-Dmodule_root_dir=/home/user/Documents/chessy/node_modules/gl',
gyp info spawn args   '-Dnode_engine=v8',
gyp info spawn args   '--depth=.',
gyp info spawn args   '--no-parallel',
gyp info spawn args   '--generator-output',
gyp info spawn args   'build',
gyp info spawn args   '-Goutput_dir=.'
gyp info spawn args ]
/bin/sh: 1: python: not found
gyp: Call to 'python commit_id.py check ..' returned exit status 127 while in angle/src/angle.gyp. while loading dependencies of binding.gyp while trying to load binding.gyp
gyp ERR! configure error 
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/home/user/Documents/chessy/node_modules/node-gyp/lib/configure.js:325:16)
gyp ERR! stack     at ChildProcess.emit (node:events:514:28)
gyp ERR! stack     at ChildProcess._handle.onexit (node:internal/child_process:294:12)
gyp ERR! System Linux 6.2.6-76060206-generic
gyp ERR! command "/home/linuxbrew/.linuxbrew/Cellar/node/20.5.0/bin/node" "/home/user/Documents/chessy/node_modules/gl/node_modules/.bin/node-gyp" "rebuild"
gyp ERR! cwd /home/user/Documents/chessy/node_modules/gl
gyp ERR! node -v v20.5.0
gyp ERR! node-gyp -v v9.4.0
gyp ERR! not ok
skulldoggery commented 11 months ago

Looks like gyp finds python (as python3) but your shell doesn't.

For kicks, can you share the output of running simply python --version and python3 --version in bash respectively?

I think a simple solution, if only the latter works, would be to alias python3 to python by adding this line to your .bashrc profile:

alias python=python3

You can simply run the above in your shell and try installing again, but the change will be for the duration of that session. If you want to persist it by adding it to your bash profile, you'll also need to run source ~/.bashrc after the addition, or just create a new session.

Let us know how it goes!

cclauss commented 11 months ago

You might need python-is-python3:

Or better yet create a venv with python3 -m venv .venv && source .venv/bin/activate

skulldoggery commented 11 months ago

@cclauss 's recommendation is also a good one and essentially does the same thing I described, as a system-wide package

sudo apt-get install python-is-python3

Some light reading on what this package does and possible drawbacks/considerations.

kul-sudo commented 11 months ago

Looks like gyp finds python (as python3) but your shell doesn't.

For kicks, can you share the output of running simply python --version and python3 --version in bash respectively?

I think a simple solution, if only the latter works, would be to alias python3 to python by adding this line to your .bashrc profile:

alias python=python3

You can simply run the above in your shell and try installing again, but the change will be for the duration of that session. If you want to persist it by adding it to your bash profile, you'll also need to run source ~/.bashrc after the addition, or just create a new session.

Let us know how it goes!

I used Homebrew to install Python and have already set the alias like that, but still get the error when trying to install GPU.js that it wants me to install.

kul-sudo commented 11 months ago

@cclauss 's recommendation is also a good one and essentially does the same thing I described, as a system-wide package

sudo apt-get install python-is-python3

Some light reading on what this package does and possible drawbacks/considerations.

I remember I have already tried this package, but still got the error. Also, the alias command is the same as installing this package, isn't it?

kul-sudo commented 11 months ago

You might need python-is-python3:

Or better yet create a venv with python3 -m venv .venv && source .venv/bin/activate

Will it work when I deploy my Next.js project with Brain.js to Vercel?

cclauss commented 11 months ago

Yes.

EDIT: Yes, for Python venv.

kul-sudo commented 11 months ago

Yes.

I have set an alias, but still get the following error when doing yarn add gpu.js:

error /home/user/Documents/chessy/node_modules/gl: Command failed.
Exit code: 1
Command: prebuild-install || node-gyp rebuild
Arguments: 
Directory: /home/user/Documents/chessy/node_modules/gl
Output:
prebuild-install warn install No prebuilt binaries found (target=20.5.0 runtime=node arch=x64 libc= platform=linux)
gyp info it worked if it ends with ok
gyp info using node-gyp@9.4.0
gyp info using node@20.5.0 | linux | x64
gyp info find Python using Python version 3.11.4 found at "/home/linuxbrew/.linuxbrew/opt/python@3.11/bin/python3.11"
gyp info spawn /home/linuxbrew/.linuxbrew/opt/python@3.11/bin/python3.11
gyp info spawn args [
gyp info spawn args   '/home/user/Documents/chessy/node_modules/node-gyp/gyp/gyp_main.py',
gyp info spawn args   'binding.gyp',
gyp info spawn args   '-f',
gyp info spawn args   'make',
gyp info spawn args   '-I',
gyp info spawn args   '/home/user/Documents/chessy/node_modules/gl/build/config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/home/user/Documents/chessy/node_modules/node-gyp/addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/home/user/.cache/node-gyp/20.5.0/include/node/common.gypi',
gyp info spawn args   '-Dlibrary=shared_library',
gyp info spawn args   '-Dvisibility=default',
gyp info spawn args   '-Dnode_root_dir=/home/user/.cache/node-gyp/20.5.0',
gyp info spawn args   '-Dnode_gyp_dir=/home/user/Documents/chessy/node_modules/node-gyp',
gyp info spawn args   '-Dnode_lib_file=/home/user/.cache/node-gyp/20.5.0/<(target_arch)/node.lib',
gyp info spawn args   '-Dmodule_root_dir=/home/user/Documents/chessy/node_modules/gl',
gyp info spawn args   '-Dnode_engine=v8',
gyp info spawn args   '--depth=.',
gyp info spawn args   '--no-parallel',
gyp info spawn args   '--generator-output',
gyp info spawn args   'build',
gyp info spawn args   '-Goutput_dir=.'
gyp info spawn args ]
/bin/sh: 1: python: not found
gyp: Call to 'python commit_id.py check ..' returned exit status 127 while in angle/src/angle.gyp. while loading dependencies of binding.gyp while trying to load binding.gyp
gyp ERR! configure error 
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/home/user/Documents/chessy/node_modules/node-gyp/lib/configure.js:325:16)
gyp ERR! stack     at ChildProcess.emit (node:events:514:28)
gyp ERR! stack     at ChildProcess._handle.onexit (node:internal/child_process:294:12)
gyp ERR! System Linux 6.2.6-76060206-generic
gyp ERR! command "/home/linuxbrew/.linuxbrew/Cellar/node/20.5.0/bin/node" "/home/user/Documents/chessy/node_modules/gl/node_modules/.bin/node-gyp" "rebuild"
gyp ERR! cwd /home/user/Documents/chessy/node_modules/gl
gyp ERR! node -v v20.5.0
gyp ERR! node-gyp -v v9.4.0
gyp ERR! not ok
kul-sudo commented 11 months ago

@cclauss also, thanks for the pull request. I'll check it out. https://github.com/BrainJS/brain.js/pull/905

cclauss commented 11 months ago

My "Yes" was for Python venv.

kul-sudo commented 11 months ago

Yes.

I have set an alias, but still get the following error when doing yarn add gpu.js:

error /home/user/Documents/chessy/node_modules/gl: Command failed.
Exit code: 1
Command: prebuild-install || node-gyp rebuild
Arguments: 
Directory: /home/user/Documents/chessy/node_modules/gl
Output:
prebuild-install warn install No prebuilt binaries found (target=20.5.0 runtime=node arch=x64 libc= platform=linux)
gyp info it worked if it ends with ok
gyp info using node-gyp@9.4.0
gyp info using node@20.5.0 | linux | x64
gyp info find Python using Python version 3.11.4 found at "/home/linuxbrew/.linuxbrew/opt/python@3.11/bin/python3.11"
gyp info spawn /home/linuxbrew/.linuxbrew/opt/python@3.11/bin/python3.11
gyp info spawn args [
gyp info spawn args   '/home/user/Documents/chessy/node_modules/node-gyp/gyp/gyp_main.py',
gyp info spawn args   'binding.gyp',
gyp info spawn args   '-f',
gyp info spawn args   'make',
gyp info spawn args   '-I',
gyp info spawn args   '/home/user/Documents/chessy/node_modules/gl/build/config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/home/user/Documents/chessy/node_modules/node-gyp/addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/home/user/.cache/node-gyp/20.5.0/include/node/common.gypi',
gyp info spawn args   '-Dlibrary=shared_library',
gyp info spawn args   '-Dvisibility=default',
gyp info spawn args   '-Dnode_root_dir=/home/user/.cache/node-gyp/20.5.0',
gyp info spawn args   '-Dnode_gyp_dir=/home/user/Documents/chessy/node_modules/node-gyp',
gyp info spawn args   '-Dnode_lib_file=/home/user/.cache/node-gyp/20.5.0/<(target_arch)/node.lib',
gyp info spawn args   '-Dmodule_root_dir=/home/user/Documents/chessy/node_modules/gl',
gyp info spawn args   '-Dnode_engine=v8',
gyp info spawn args   '--depth=.',
gyp info spawn args   '--no-parallel',
gyp info spawn args   '--generator-output',
gyp info spawn args   'build',
gyp info spawn args   '-Goutput_dir=.'
gyp info spawn args ]
/bin/sh: 1: python: not found
gyp: Call to 'python commit_id.py check ..' returned exit status 127 while in angle/src/angle.gyp. while loading dependencies of binding.gyp while trying to load binding.gyp
gyp ERR! configure error 
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/home/user/Documents/chessy/node_modules/node-gyp/lib/configure.js:325:16)
gyp ERR! stack     at ChildProcess.emit (node:events:514:28)
gyp ERR! stack     at ChildProcess._handle.onexit (node:internal/child_process:294:12)
gyp ERR! System Linux 6.2.6-76060206-generic
gyp ERR! command "/home/linuxbrew/.linuxbrew/Cellar/node/20.5.0/bin/node" "/home/user/Documents/chessy/node_modules/gl/node_modules/.bin/node-gyp" "rebuild"
gyp ERR! cwd /home/user/Documents/chessy/node_modules/gl
gyp ERR! node -v v20.5.0
gyp ERR! node-gyp -v v9.4.0
gyp ERR! not ok

Both python3 --version and python --version log the same version, but I still have the error. I actually at the moment am a bit confused.

Keep in mind, it is all Next.js.

cclauss commented 11 months ago

What are the results of python3 --version ? What are the contents of binding.gyp?

Oh... stackgl/headless-gl#221

kul-sudo commented 11 months ago

What are the results of python3 --version ? What are the contents of binding.gyp?

Oh... stackgl/headless-gl#221

The "Oh..." has made me oddly satisfied. So I need to install Python 2, don't I? This is what is apparently said in the thread.

kul-sudo commented 11 months ago

python3 --version: Python 3.11.4 Where can I find binding.gyp?

kul-sudo commented 11 months ago

Sorry for sending several messages instead of sending one with everything, but I think I have found a temporary solution which is to install an older version of gpu.js, to wit, 1.10.4, but it must not be the final solution.

cclauss commented 11 months ago

Also see: https://github.com/mikolalysenko/angle/pull/5

kul-sudo commented 11 months ago

Also see: https://github.com/mikolalysenko/angle/pull/5

Hope what you have done will contribute to this problem getting finally fixed.

romaleev commented 7 months ago

Had the same as initial post's stack-trace during install on Mac OS Ventura using python from brew, fixed with:

cd /opt/homebrew/bin
sudo ln -sf python3 python
cclauss commented 7 months ago

@romaleev bad idea but hey, it is your machine.