mkleehammer / pyodbc

Python ODBC bridge
https://github.com/mkleehammer/pyodbc/wiki
MIT No Attribution
2.89k stars 562 forks source link

"Visual C++ … is required" error when running "pip install pyodbc" #1047

Closed joshssc closed 2 years ago

joshssc commented 2 years ago

as i do not see this reported, at least not with detail... this was after installing the visual c ++ on the page linked in the install ....

C:\Users\dt234927\OneDrive - SS&C Technologies, Inc\Documents\Projects\AttestationInformation>pip install pyodbc Collecting pyodbc Using cached pyodbc-4.0.32.tar.gz (280 kB) Preparing metadata (setup.py) ... done Using legacy 'setup.py install' for pyodbc, since package 'wheel' is not installed. Installing collected packages: pyodbc Running setup.py install for pyodbc ... error error: subprocess-exited-with-error

× Running setup.py install for pyodbc did not run successfully. │ exit code: 1 ╰─> [5 lines of output] running install running build running build_ext building 'pyodbc' 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: legacy-install-failure

× Encountered error while trying to install package. ╰─> pyodbc

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

C:\Users\dt234927\OneDrive - SS&C Technologies, Inc\Documents\Projects\AttestationInformation>winver

C:\Users\dt234927\OneDrive - SS&C Technologies, Inc\Documents\Projects\AttestationInformation>ver

Microsoft Windows [Version 10.0.19044.1586]

C:\Users\dt234927\OneDrive - SS&C Technologies, Inc\Documents\Projects\AttestationInformation>

joshssc commented 2 years ago

full link to c++ installed: https://aka.ms/vs/17/release/vc_redist.x64.exe

gordthompson commented 2 years ago

"vc_redist.x64.exe" installs the

MICROSOFT VISUAL C++ 2015 - 2022 RUNTIME

which is a bunch of pre-compiled libraries that allow us to run C++ applications, not compile them.

To compile pyodbc we need to download the

"Microsoft C++ Build Tools"

via the "Download" button at

https://visualstudio.microsoft.com/visual-cpp-build-tools/

and run it. When prompted for the "Workloads" to install, choose "Desktop development with C++".

joshssc commented 2 years ago

TY. the initial install did not work. but going and modifying i noticed a few extra C compiler options. i added them (did not have time to test which one it was) and then it worked