wloleo
wloleo

Reputation: 2160

How to solve "error: Microsoft Visual C++ 14.0 or greater is required" when installing Python packages?

I'm trying to install a package on Python, but Python is throwing an error on installing packages. I'm getting an error every time I tried to install pip install google-search-api.

Here is the error how can I successfully install it?

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/

I already updated that and have the latest version of 14.27 but the problem is throwing the same error.

Upvotes: 221

Views: 625725

Answers (11)

Dipesh Satav
Dipesh Satav

Reputation: 45

The answer by @ice-bear is the solution to this question. However, the size of the installs is around 5gb and I had very small amount of memory left. One fix which worked for me is using PortableBuildTools. It only has the minimum required components for your build.
Download and run the application, make sure to create scripts and add to environment when installing.

add to env

Finally , if you are installing within an existing conda environment , make sure you add the newly added variables to the conda environment, since it won't automatically detect them.

Upvotes: 0

vortex
vortex

Reputation: 123

The visual studio build tool did not work me. I manually fixed it.

I went to this repo: https://github.com/cgohlke/talib-build/?tab=readme-ov-file#talib-build

and followed the instruction there:

"The wheels can be downloaded from the Releases page. Install a wheel on the command line, for example for Python 3.11 64-bit:"

python -m pip install TA_Lib-0.4.28-cp311-cp311-win_amd64.whl 

Upvotes: -2

xlc
xlc

Reputation: 73

I have encountered the same error, due to multidict, and solved it thanks to:

Picture

pip install .\multidict-6.0.2-py3-none-any.whl 

Upvotes: 2

Wok
Wok

Reputation: 5313

This error can happen when using the latest version of Python, e.g. 3.12, because the package wheels were only built for earlier versions of Python. So you have to build them by yourself.

Thankfully, you may download wheels built by a third-party and shared online at:

This allows:

  • to bypass the download of GB of Visual Studio Build Tools,
  • to avoid downgrading your version of Python.

Typically, if the error message is the following:

Failed to build frozenlist multidict

Then you should download:

  • frozenlist: frozenlist‑1.3.0‑py3‑none‑any.whl
  • multidict: multidict‑6.0.2‑py3‑none‑any.whl

And run locally:

pip install .\frozenlist-1.3.0-py3-none-any.whl
pip install .\multidict-6.0.2-py3-none-any.whl 

Finally, resume the installation which was previously failing:

pip install -r .\requirements.txt 

This time, the installation should succeed.

Upvotes: 18

Crotonix
Crotonix

Reputation: 27

Wanted to comment on xlc's approach(couldn't) as it worked for me. I had conda virtual environment with Python 3.11.4. When i tried to install TA-Lib got an error:

Blockquote 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]

Downloading the build tools was not an option for me(due to 6GB size). This is what worked for me:

  • Went to https://www.lfd.uci.edu/%7Egohlke/pythonlibs/#multidict and found .whl was available for python 3.10(TA_Lib‑0.4.24‑cp310‑cp310‑win_amd64.whl for x64 system)
  • Downgraded version of my environment to 3.10
  • Downloaded the appropriate .whl from above link
  • installed the wheel directly using pip install directory_wheel in anaconda prompt

Also used this for reference>https://stackoverflow.com/questions/74651107/failed-to-build-ta-lib-error-could-not-build-wheels-for-ta-lib-which-is-requir

Upvotes: 1

Prason Ghimire
Prason Ghimire

Reputation: 529

  1. Upgrade your pip with: python -m pip install --upgrade pip
  2. Upgrade your wheel with: pip install --upgrade wheel
  3. Upgrade your setuptools with: pip install --upgrade setuptools
  4. Close the terminal
  5. Try installing the package again.

Upvotes: -2

Andrey Aristov
Andrey Aristov

Reputation: 21

I encounered the above-mentionned problem when using virtualenv. Using conda environment instead solved the problem. Conda automatically installs vs2015_runtime which compiles the wheels with no problem.

Upvotes: 0

Jirka Fizek
Jirka Fizek

Reputation: 87

I tried everything and then finally, downgrading from python 3.10 to 3.9 is what worked. (I noticed it in this comment, but it is a bit different scenario: https://stackoverflow.com/a/70617749/17664284 )

Upvotes: 7

Ice Bear
Ice Bear

Reputation: 4076

Go to this link and download Microsoft C++ Build Tools:
https://visualstudio.microsoft.com/visual-cpp-build-tools/

enter image description here

Open the installer, then follow the steps.

You might have something like this, just download it or resume.

MSBT

If updating above doesn't work then you need to configure or make some updates here. You can make some updates here too by clicking "Modify".

Check that and download what you need there or you might find that you just need to update Microsoft Visual C++ as stated on the error, but I also suggest updating everything there because you might still need it on your future programs. I think those with the C++ as I've done that before and had a similar problem just like that when installing a python package for creating WorldCloud visualization.

C++ Build tools


UPDATE: December 28, 2020

You can also follow these steps here:

  1. Select: Workloads → Desktop development with C++
  2. Then for Individual Components, select only:
    • Windows 10 SDK
    • C++ x64/x86 build tools

You can also achieve the same automatically using the following command:

vs_buildtools.exe --norestart --passive --downloadThenInstall --includeRecommended --add Microsoft.VisualStudio.Workload.NativeDesktop --add Microsoft.VisualStudio.Workload.VCTools --add Microsoft.VisualStudio.Workload.MSBuildTools

Reference:
https://www.scivision.dev/python-windows-visual-c-14-required

Upvotes: 330

yue fei
yue fei

Reputation: 7

Tried Prason's approach. Also tried the fix suggested here

  1. conda install -c conda-forge implicit
  2. pip install --upgrade gensim

Upvotes: -6

Lawrence Patrick
Lawrence Patrick

Reputation: 379

2020 - redist/build tools for Visual C++

silent installs can be done using the following two commands :

vs_buildtools__370953915.1537938681.exe --quiet --add Microsoft.VisualStudio.Workload.VCTools

and

VC_redist.x64.exe  /q /norestart

Upvotes: 5

Related Questions