1

I have been trying to install the python package annoy but it always gives an error, I have tried different methods but they don't work. I have even tried to install the module manually but it does not work either My Code:

pip install annoy

Error:

Collecting annoy


Using cached annoy-1.17.0.tar.gz (646 kB)
  Preparing metadata (setup.py): started
  Preparing metadata (setup.py): finished with status 'done'
Building wheels for collected packages: annoy
  Building wheel for annoy (setup.py): started
  Building wheel for annoy (setup.py): finished with status 'error'
  Running setup.py clean for annoy
Failed to build annoy
Installing collected packages: annoy
  Running setup.py install for annoy: started
  Running setup.py install for annoy: finished with status 'error'

  error: subprocess-exited-with-error
  
  python setup.py bdist_wheel did not run successfully.
  exit code: 1
  
  [18 lines of output]
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build\lib.win-amd64-3.10
  creating build\lib.win-amd64-3.10\annoy
  copying annoy\__init__.py -> build\lib.win-amd64-3.10\annoy
  warning: build_py: byte-compiling is disabled, skipping.
  
  running build_ext
  building 'annoy.annoylib' extension
  creating build\temp.win-amd64-3.10
  creating build\temp.win-amd64-3.10\Release
  creating build\temp.win-amd64-3.10\Release\src
  C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -IC:\Users\Tainu\AppData\Local\Programs\Python\Python310\include -IC:\Users\Tainu\AppData\Local\Programs\Python\Python310\Include -IC:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133\include -IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\include\um /EHsc /Tpsrc/annoymodule.cc /Fobuild\temp.win-amd64-3.10\Release\src/annoymodule.obj -D_CRT_SECURE_NO_WARNINGS -DANNOYLIB_MULTITHREADED_BUILD
  annoymodule.cc
  C:\Users\Tainu\AppData\Local\Temp\pip-install-3by5ea7a\annoy_d20fa133de45438cb5f39d6b5b50b96b\src\annoylib.h(19): fatal error C1083: Cannot open include file: 'stdio.h': No such file or directory
  error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\VC\\Tools\\MSVC\\14.29.30133\\bin\\HostX86\\x64\\cl.exe' failed with exit code 2
  [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for annoy
  error: subprocess-exited-with-error
  
  Running setup.py install for annoy did not run successfully.
  exit code: 1
  
  [18 lines of output]
  running install
  running build
  running build_py
  creating build
  creating build\lib.win-amd64-3.10
  creating build\lib.win-amd64-3.10\annoy
  copying annoy\__init__.py -> build\lib.win-amd64-3.10\annoy
  warning: build_py: byte-compiling is disabled, skipping.
  
  running build_ext
  building 'annoy.annoylib' extension
  creating build\temp.win-amd64-3.10
  creating build\temp.win-amd64-3.10\Release
  creating build\temp.win-amd64-3.10\Release\src
  C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -IC:\Users\Tainu\AppData\Local\Programs\Python\Python310\include -IC:\Users\Tainu\AppData\Local\Programs\Python\Python310\Include -IC:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133\include -IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\include\um /EHsc /Tpsrc/annoymodule.cc /Fobuild\temp.win-amd64-3.10\Release\src/annoymodule.obj -D_CRT_SECURE_NO_WARNINGS -DANNOYLIB_MULTITHREADED_BUILD
  annoymodule.cc
  C:\Users\Tainu\AppData\Local\Temp\pip-install-3by5ea7a\annoy_d20fa133de45438cb5f39d6b5b50b96b\src\annoylib.h(19): fatal error C1083: Cannot open include file: 'stdio.h': No such file or directory
  error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\VC\\Tools\\MSVC\\14.29.30133\\bin\\HostX86\\x64\\cl.exe' failed with exit code 2
  [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure

Encountered error while trying to install package.

annoy

note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.

My python version is 3.10, Windows 11 64-bit I am using Pycharm any help would be welcome

Odysseus
  • 53
  • 1
  • 7

2 Answers2

3

Below command worked in my case.

pipwin install annoy
Shahzad07
  • 49
  • 4
-2

Try installing with conda.

A lot of libraries that require C/C++ code to be compiled as part of their build and installation can be finicky on windows machines.

https://anaconda.org/conda-forge/python-annoy

This article might help too

https://www.programmersought.com/article/95834605670/

myz540
  • 537
  • 4
  • 7