hnswlib-node icon indicating copy to clipboard operation
hnswlib-node copied to clipboard

I have this problem to install hnswlib-node

Open intellydev opened this issue 1 year ago • 5 comments

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.

intellydev avatar Feb 24 '24 18:02 intellydev

Facing same issue, any update on this?

poojagupta-trilogy avatar Mar 21 '24 03:03 poojagupta-trilogy

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";

wasiq-97 avatar Mar 22 '24 20:03 wasiq-97

@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: https://github.com/nodejs/node-gyp/issues/2869 https://stackoverflow.com/questions/69919970/no-module-named-distutils-but-distutils-installed/76691103#76691103

yoshoku avatar Mar 27 '24 12:03 yoshoku

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

Genuifx avatar May 13 '24 11:05 Genuifx

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

beytarovski avatar May 20 '24 07:05 beytarovski