Unable to install Brain.js on PopOS
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 [email protected]
npm ERR! gyp info using [email protected] | linux | x64
npm ERR! gyp info find Python using Python version 3.11.4 found at "/home/linuxbrew/.linuxbrew/opt/[email protected]/bin/python3.11"
npm ERR! gyp info spawn /home/linuxbrew/.linuxbrew/opt/[email protected]/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.
I also have noticed that many people have created similar issues, but none of them has got a clear solution that works.
Your error message - Error: Cannot find module 'gpu.js' - means you have to also do npm install gpu.js
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 [email protected]
gyp info using [email protected] | 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
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!
You might need python-is-python3:
- https://launchpad.net/ubuntu/lunar/+package/python-is-python3
- https://packages.debian.org/bookworm/python-is-python3
Or better yet create a venv with python3 -m venv .venv && source .venv/bin/activate
- https://docs.python.org/3/library/venv.html
- https://snarky.ca/how-virtual-environments-work
- https://packages.debian.org/bookworm/python3-venv
- https://packages.debian.org/bookworm/python3-full
@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.
Looks like
gypfinds python (aspython3) but your shell doesn't.For kicks, can you share the output of running simply
python --versionandpython3 --versionin bash respectively?I think a simple solution, if only the latter works, would be to alias
python3topythonby adding this line to your.bashrcprofile:alias python=python3You 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 ~/.bashrcafter 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.
@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-python3Some 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?
You might need
python-is-python3:
- https://launchpad.net/ubuntu/lunar/+package/python-is-python3
- https://packages.debian.org/bookworm/python-is-python3
Or better yet create a venv with
python3 -m venv .venv && source .venv/bin/activate
- https://docs.python.org/3/library/venv.html
- https://snarky.ca/how-virtual-environments-work
- https://packages.debian.org/bookworm/python3-venv
- https://packages.debian.org/bookworm/python3-full
Will it work when I deploy my Next.js project with Brain.js to Vercel?
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 [email protected]
gyp info using [email protected] | linux | x64
gyp info find Python using Python version 3.11.4 found at "/home/linuxbrew/.linuxbrew/opt/[email protected]/bin/python3.11"
gyp info spawn /home/linuxbrew/.linuxbrew/opt/[email protected]/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
@cclauss also, thanks for the pull request. I'll check it out. https://github.com/BrainJS/brain.js/pull/905
My "Yes" was for Python venv.
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 [email protected] gyp info using [email protected] | linux | x64 gyp info find Python using Python version 3.11.4 found at "/home/linuxbrew/.linuxbrew/opt/[email protected]/bin/python3.11" gyp info spawn /home/linuxbrew/.linuxbrew/opt/[email protected]/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.
What are the results of python3 --version ?
What are the contents of binding.gyp?
Oh... stackgl/headless-gl#221
What are the results of
python3 --version? What are the contents ofbinding.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.
python3 --version: Python 3.11.4
Where can I find binding.gyp?
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.
Also see: https://github.com/mikolalysenko/angle/pull/5
Also see: https://github.com/mikolalysenko/angle/pull/5
Hope what you have done will contribute to this problem getting finally fixed.
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
@romaleev bad idea but hey, it is your machine.
- https://snarky.ca/how-virtual-environments-work from a longtime Python code dev.