Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to install Brain.js on PopOS #904

Open
kul-sudo opened this issue Jul 23, 2023 · 24 comments
Open

Unable to install Brain.js on PopOS #904

kul-sudo opened this issue Jul 23, 2023 · 24 comments
Labels

Comments

@kul-sudo
Copy link

kul-sudo commented Jul 23, 2023

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 [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.

@kul-sudo kul-sudo added the bug label Jul 23, 2023
@kul-sudo
Copy link
Author

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

@seunafara
Copy link

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

@kul-sudo
Copy link
Author

kul-sudo commented Jul 24, 2023

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

@skulldoggery
Copy link

skulldoggery commented Jul 24, 2023

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
Copy link
Contributor

cclauss commented Jul 24, 2023

You might need python-is-python3:

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

@skulldoggery
Copy link

skulldoggery commented Jul 24, 2023

@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
Copy link
Author

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
Copy link
Author

@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
Copy link
Author

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
Copy link
Contributor

cclauss commented Jul 24, 2023

Yes.

EDIT: Yes, for Python venv.

@kul-sudo
Copy link
Author

kul-sudo commented Jul 24, 2023

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

@kul-sudo
Copy link
Author

@cclauss also, thanks for the pull request. I'll check it out.
#905

@cclauss
Copy link
Contributor

cclauss commented Jul 24, 2023

My "Yes" was for Python venv.

@kul-sudo
Copy link
Author

kul-sudo commented Jul 24, 2023

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.

@cclauss
Copy link
Contributor

cclauss commented Jul 24, 2023

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

Oh... stackgl/headless-gl#221

@kul-sudo
Copy link
Author

kul-sudo commented Jul 24, 2023

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
Copy link
Author

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

@kul-sudo
Copy link
Author

kul-sudo commented Jul 24, 2023

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
Copy link
Contributor

cclauss commented Jul 26, 2023

Also see: mikolalysenko/angle#5

@kul-sudo
Copy link
Author

Also see: mikolalysenko/angle#5

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

@romaleev
Copy link

romaleev commented Nov 29, 2023

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
Copy link
Contributor

cclauss commented Nov 29, 2023

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

@Morty135
Copy link

I had the same problem on Manjaro linux, somehow changing the node version from 20 to 16 fixed the problem. I tested it with multiple versions of node on both my ubuntu VM and my Manjaro machine and found out that brain.js couldnt install on anything newer than node 16.

@cclauss
Copy link
Contributor

cclauss commented Aug 29, 2024

npm ERR! path /home/user/Documents/chessy/node_modules/gl

Does npm install gl work?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants