mkleehammer / pyodbc

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

Windows 11. Python 3.10.1 Impossible to install pyodbc #1010

Closed grey-bee closed 2 years ago

grey-bee commented 2 years ago

Python 64x. The fresh version of PIP, Installed VC for 2015, 2017, 2019, and 2022 for 64 and x86(I tried this step too). But..................................... 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: Command errored out with exit status 1: command: 'C:\Users\admin\AppData\Local\Programs\Python\Python310\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Users\admin\AppData\Local\Temp\pip-install-_j4jyamk\pyodbc_a2017b7ad25e4c76810be58b636f4e0b\setup.py'"'"'; file='"'"'C:\Users\admin\AppData\Local\Temp\pip-install-_j4jyamk\pyodbc_a2017b7ad25e4c76810be58b636f4e0b\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(file) if os.path.exists(file) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' install --record 'C:\Users\admin\AppData\Local\Temp\pip-record-mz0r0ege\install-record.txt' --single-version-externally-managed --compile --install-headers 'C:\Users\admin\AppData\Local\Programs\Python\Python310\Include\pyodbc' cwd: C:\Users\admin\AppData\Local\Temp\pip-install-_j4jyamk\pyodbc_a2017b7ad25e4c76810be58b636f4e0b\ Complete output (5 lines): 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/

PyODBC doesn't see VC. :(

gordthompson commented 2 years ago

Related: #981

grey-bee commented 2 years ago

I found the solution! It's problem with Microsoft products. Very easy to solve - and I think MS should add this info to all their products. If you can't install these plugins as well, need to download it from other repositories like this one: https://www.lfd.uci.edu/~gohlke/pythonlibs/ depends on the version of python and the system. for example: for my windows 11(x64) and python 3.10 I took this file: pyodbc‑4.0.32‑cp310‑cp310‑win_amd64.whl it's very easy to install: pip install pyodbc‑4.0.32‑cp310‑cp310‑win_amd64.whl after it system works well and didn't ask you about VC. This solution I found in problem with the MySql plugin for Django. I don't understand why - but they also use VC for the installation process. People also are in shock with the recommendation to install Studio with 16 GB with unusable information! Microsoft team!!! Please stop doing it!!! Why for all your product we should be finding a solution for installation? It's a quest?

grey-bee commented 2 years ago

Related: #981

thank you very much. I will add info to this topic too!

sandarbhasthana commented 2 years ago

Thanks, @gordthompson !!

xpil commented 1 year ago

Python 3.11.0 on Win 11 here. Same issue when the parent package (dbt-sqlserver) is trying to uninstall and then re-install pyodbc, ending up with the same error message.

So, pyodbc installs fine on its own but fails (with a wrong "Microsoft Visual C++ 14.0 or greater is required" error message) when installed by another package.

gordthompson commented 1 year ago

@xpil - dbt-sqlserver is trying to install pyodbc 4.0.32:

Collecting pyodbc==4.0.32
  Using cached pyodbc-4.0.32.tar.gz (280 kB)
  Preparing metadata (setup.py) ... done

pyodbc didn't have wheels for Python 3.11 until version 4.0.35.

xpil commented 1 year ago

Thanks for clarification. I am relatively new to Python and I do not really understand what it means. Should I downgrade to Python 3.10.x to work around this issue? Can I (somehow?) make the dbt-sqlserver package use a newer version of pyodbc? What are my options (if any)?

gordthompson commented 1 year ago

Probably the best solution would be to contact the maintainers of dbt-sqlserver and ask them why they are installing an older version of pyodbc.