Why do I get error while installing gensim package

425 views Asked by At
Building wheels for collected packages: gensim
  Building wheel for gensim (pyproject.toml) ... error
  error: subprocess-exited-with-error

  × Building wheel for gensim (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [714 lines of output]

building 'gensim.models.word2vec_inner' extension
      error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for gensim
Failed to build gensim
ERROR: Could not build wheels for gensim, which is required to install pyproject.toml-based projects

I tried a couple of things but nothing seems to work, please let me know how we can resolve this issue?

1

There are 1 answers

0
gojomo On

Building the supporting native libraries on Windows machines can be somewhat finicky requiring extra tools, & different from the better-supported Unix-ish (Linux/MacOS) environments.

So, if your Windows install is trying that rather than using some precompiled wheels, the situation is suboptimal and likely to fail without hand-holding.

You may be using Python 3.12, for which (as of this answer in early February 2024) Gensim hasn't yet ensured prebuilt wheels for all environments – see open project issues #3510 & #3511, which should eventually be fixed so that standard pip installs just work.

Until then, your best workaround may be to use a slightly-older Python like 3.11. A tool like conda can make it easy to manage virtual environments that use specific Python versions, such as those older or newer than your system's standard Python. (I prefer the miniconda install for keeping things simple and explicit.)