Search code examples
pythonpipword2vec

Could not build wheels for word2vec, which is required to install pyproject.toml-based projects


the error appears after trying to install word2vec in Jupyter Notebook:

!pip install word2vec


  Compiling: gcc C:\Users\Mikhail\AppData\Local\Temp\pip-install-npzfmr51\word2vec_1d22636dcb264535b7c0bcd56e9c8d55\word2vec\includes\win32/word2vec.c -o Scripts\word2vec.exe -O2 -Wall -funroll-loops
  error: [WinError 2] Не удается найти указанный файл
  [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for word2vec
ERROR: Could not build wheels for word2vec, which is required to install pyproject.toml-based projects

I have already tried to reinstall python, update pip, install specific realises of Python. Nothing helps. I know that for many people installation of python 3.8 solves the problem, but that's not my case as well.


Solution

  • Unless you are on an uncommon OS configuration, you should generally not need to be building your own local wheels for popular libraries like Gensim.

    Rather, the right choice of local versions & remote package-repositories should result in the installation of prebuilt, tested packages well-matched to your local system.

    So, even if you could make this local build work (by tinkering with the right build-tools, or addressing whatever that error-reported-in-Cyrillic-is), seeing such a build proceed suggests things are suboptimal.

    How did you "reinstall Python"? Did you replace the system Python (which could introduce other issues), or make a separate installation for the specific use of your project?

    If the initial error was because you were originally using some leading-edge Python, then rolling to another better-supported Python (eg 3.8.x) should help – but you'd have to make sure that was the Python being used by your Jupyter service, for your specific notebook... which might not be the case.

    In general, also, it's best to use project-specific Python virtual environments, rather than the system Python, for more control over versions/libraries, without cross-interference from the competing needs of the system Python and other projects.

    In particular, the conda tool offers fine-grained control of multiple Python versions for multiple independent virtual environments - so your system Python can remain whatever the OS prefers, while you use some other version just for Jupyter or individual notebooks. (I prefer to start with the miniconda install – https://docs.conda.io/projects/conda/en/latest/user-guide/install/windows.html – so as not to bring in excess unneeded libraries, and keep things very explicit as to how I build up each new virtual environment for each coding project's needs.)