Alankar Gupta
Alankar Gupta

Reputation: 201

"Microsoft Visual C++ … is required" error when trying to install pyodbc on Windows

I am trying to install pyodbc, and I am getting the below error.

C:\Python\Python37\Scripts>pip3 install pyodbc

Output

Collecting pyodbc
  Using cached https://files.pythonhosted.org/packages/aa/71/cef225c4889620a1a00251d24c1746fe0cf4124290a75d1c2dc5c187b61f/pyodbc-4.0.23.tar.gz
Installing collected packages: pyodbc
  Running setup.py install for pyodbc ... error
    Complete output from command c:\python\python37\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\Alankar\\AppData\\Local\\Temp\\pip-install-7qf14pkz\\pyodbc\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\Alankar\AppData\Local\Temp\pip-record-k11gmg0x\install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_ext
    building 'pyodbc' extension
    error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": http://landinghub.visualstudio.com/visual-cpp-build-tools

Command "c:\python\python37\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\Alankar\\AppData\\Local\\Temp\\pip-install-7qf14pkz\\pyodbc\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\Alankar\AppData\Local\Temp\pip-record-k11gmg0x\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:\Users\Alankar\AppData\Local\Temp\pip-install-7qf14pkz\pyodbc\

Upvotes: 4

Views: 8509

Answers (4)

Michael
Michael

Reputation: 191

If none of the other answers work: I was running the newest version of python and it was giving me this error. As soon as I downgraded to 3.8.x it worked like a charm using pip install

Upvotes: 0

Julian Eccleshall
Julian Eccleshall

Reputation: 554

the install failed on my machine even after I installed Microsoft VC++ build tools, my solution for this is install an early version. the newer version assume you have VC++ and VS 2019 installed.

run this command

pip install -Iv pyodbc==4.0.27

Upvotes: 2

MarredCheese
MarredCheese

Reputation: 20791

I couldn't get the C++ build tools method to work, but I found this method to be very straightforward:

  1. Download the relevant pyodbc wheel (pre-compiled binary) based on your computer's architecture and version of Python: https://www.lfd.uci.edu/~gohlke/pythonlibs/#pyodbc
  2. Run pip install <wheel path>.

For example:

pip install c:\users\bob\downloads\pyodbc-4.0.27-cp38-cp38-win_amd64.whl

Upvotes: 7

FightWithCode
FightWithCode

Reputation: 2252

Some Libraries require C++ build tools to install. In your case, to solve this problem there are two methods which are:

Update the pip's Setup tool:

To fix your error update the setup tool by this command:

pip install --upgrade setuptools

And the second method is to:

Install the Microsoft Visual C++ Build Tools

This can also be fixed by installing this little tool provided by Microsoft: https://visualstudio.microsoft.com/visual-cpp-build-tools/

Upvotes: 2

Related Questions