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

I have this problem to install hnswlib-node #176

Open
intellydev opened this issue Feb 24, 2024 · 5 comments
Open

I have this problem to install hnswlib-node #176

intellydev opened this issue Feb 24, 2024 · 5 comments

Comments

@intellydev
Copy link

I cant install hnswlib-node :/

PS D:\langchain-workshop-master> pnpm i hnswlib-node Packages: +5 -1 +++++- Progress: resolved 116, reused 94, downloaded 0, added 5, done node_modules/.pnpm/[email protected]/node_modules/hnswlib-node: Running install script, failed in 1.2s .../node_modules/hnswlib-node install$ node-gyp rebuild │ D:\langchain-workshop-master\node_modules\.pnpm\[email protected]\node_modules\hnswlib-node>if not defined npm_con… │ gyp info it worked if it ends with ok │ gyp info using [email protected] │ gyp info using [email protected] | win32 | x64 │ gyp info find Python using Python version 3.12.1 found at "C:\Users\FAMILIA\AppData\Local\Programs\Python\Python312… │ gyp info find VS using VS2022 (17.8.34511.84) found at: │ gyp info find VS "C:\Program Files\Microsoft Visual Studio\2022\Community" │ gyp info find VS run with --verbose for detailed information │ gyp info spawn C:\Users\FAMILIA\AppData\Local\Programs\Python\Python312\python.exe │ gyp info spawn args [ │ gyp info spawn args 'C:\\Users\\FAMILIA\\AppData\\Roaming\\npm\\node_modules\\pnpm\\dist\\node_modules\\node-gyp\… │ gyp info spawn args 'binding.gyp', │ gyp info spawn args '-f', │ gyp info spawn args 'msvs', │ gyp info spawn args '-I', │ gyp info spawn args 'D:\\langchain-workshop-master\\node_modules\\.pnpm\\[email protected]\\node_modules\\hnswli… │ gyp info spawn args '-I', │ gyp info spawn args 'C:\\Users\\FAMILIA\\AppData\\Roaming\\npm\\node_modules\\pnpm\\dist\\node_modules\\node-gyp\… │ gyp info spawn args '-I', │ gyp info spawn args 'C:\\Users\\FAMILIA\\AppData\\Local\\node-gyp\\Cache\\18.17.1\\include\\node\\common.gypi', │ gyp info spawn args '-Dlibrary=shared_library', │ gyp info spawn args '-Dvisibility=default', │ gyp info spawn args '-Dnode_root_dir=C:\\Users\\FAMILIA\\AppData\\Local\\node-gyp\\Cache\\18.17.1', │ gyp info spawn args '-Dnode_gyp_dir=C:\\Users\\FAMILIA\\AppData\\Roaming\\npm\\node_modules\\pnpm\\dist\\node_mod… │ gyp info spawn args '-Dnode_lib_file=C:\\\\Users\\\\FAMILIA\\\\AppData\\\\Local\\\\node-gyp\\\\Cache\\\\18.17.1\\… │ gyp info spawn args '-Dmodule_root_dir=D:\\langchain-workshop-master\\node_modules\\.pnpm\\[email protected]\\no… │ 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 'D:\\langchain-workshop-master\\node_modules\\.pnpm\\[email protected]\\node_modules\\hnswli… │ gyp info spawn args '-Goutput_dir=.' │ gyp info spawn args ] │ Traceback (most recent call last): │ File "C:\Users\FAMILIA\AppData\Roaming\npm\node_modules\pnpm\dist\node_modules\node-gyp\gyp\gyp_main.py", line 42… │ import gyp # noqa: E402 │ ^^^^^^^^^^ │ File "C:\Users\FAMILIA\AppData\Roaming\npm\node_modules\pnpm\dist\node_modules\node-gyp\gyp\pylib\gyp\__init__.py… │ import gyp.input │ File "C:\Users\FAMILIA\AppData\Roaming\npm\node_modules\pnpm\dist\node_modules\node-gyp\gyp\pylib\gyp\input.py", … │ from distutils.version import StrictVersion │ ModuleNotFoundError: No module named 'distutils' │ gyp ERR! configure error │ gyp ERR! stack Error: gyp failed with exit code: 1 │ gyp ERR! stack at ChildProcess.onCpExit (C:\Users\FAMILIA\AppData\Roaming\npm\node_modules\pnpm\dist\node_modul… │ gyp ERR! stack at ChildProcess.emit (node:events:514:28) │ gyp ERR! stack at ChildProcess._handle.onexit (node:internal/child_process:291:12) │ gyp ERR! System Windows_NT 10.0.19045 │ gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\FAMILIA\\AppData\\Roaming\\npm\\node_modules\\pn… │ gyp ERR! cwd D:\langchain-workshop-master\node_modules\.pnpm\[email protected]\node_modules\hnswlib-node │ gyp ERR! node -v v18.17.1 │ gyp ERR! node-gyp -v v9.4.1 │ gyp ERR! not ok └─ Failed in 1.2s at D:\langchain-workshop-master\node_modules\.pnpm\[email protected]\node_modules\hnswlib-node  ELIFECYCLE  Command failed with exit code 1.

@poojagupta-trilogy
Copy link

Facing same issue, any update on this?

@wasiq-97
Copy link

I encountered a challenge recently, but thankfully found a solution by switching to FAISS instead of hnswib. To resolve the issue, I used the following command to install FAISS:

npm install -S faiss-node

Then, I imported the FaissStore from the langchain/vectorstores/faiss module:

import { FaissStore } from "langchain/vectorstores/faiss";

@yoshoku
Copy link
Owner

yoshoku commented Mar 27, 2024

@jshell10 @poojagupta-trilogy
This issue is caused by the removal of distutils, which is required by node-gyp, from Python 3.12. By running the following command, distutils will be installed and the problem will be resolved.

$ pip install setuptools

The following links may be helpful:
nodejs/node-gyp#2869
https://stackoverflow.com/questions/69919970/no-module-named-distutils-but-distutils-installed/76691103#76691103

@Genuifx
Copy link

Genuifx commented May 13, 2024

gyp info it worked if it ends with ok
│ gyp info using [email protected]
│ gyp info using [email protected] | darwin | arm64
│ gyp info find Python using Python version 3.11.5

SyntaxError: Non-UTF-8 code starting with '\xac' in file

gyp ERR! node -v v20.10.0
│ gyp ERR! node-gyp -v v9.4.1

I get this post-install script error with python 3.11 and node 20, how to fixed it? @yoshoku

@beytarovski
Copy link

beytarovski commented May 20, 2024

If you run on MacOS, try to install python-setuptools first:

brew install python-setuptools

Then you can go with (for yarn users) 🙌:

yarn add hnswlib-node

or with npm

npm install hnswlib-node

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

No branches or pull requests

6 participants