简体   繁体   中英

How can I install pyodbc on Windows for use with Python 3.8?

I'm getting error on pyodbc install, i was studyng the problem and maybe its the c++ redistribute instalation problem, but even with c++ redistribute intalation updated the problem oc

Follow the error when o try to install pyodbc

C:\Users\MacInBox>pip install pyodbc
Collecting pyodbc
  Using cached https://files.pythonhosted.org/packages/75/29/aa190749bac37ede0f11a68a75e7055254699c11572bd94213f1163dfd8f/pyodbc-4.0.27.tar.gz
Installing collected packages: pyodbc
    Running setup.py install for pyodbc ... error
    ERROR: Command errored out with exit status 1:
     command: 'c:\users\macinbox\appdata\local\programs\python\python38-32\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\MacInBox\\AppData\\Local\\Temp\\pip-install-ysm4ul3_\\pyodbc\\setup.py'"'"'; __file__='"'"'C:\\Users\\MacInBox\\AppData\\Local\\Temp\\pip-install-ysm4ul3_\\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\MacInBox\AppData\Local\Temp\pip-record-fzctfb9u\install-record.txt' --single-version-externally-managed --compile
         cwd: C:\Users\MacInBox\AppData\Local\Temp\pip-install-ysm4ul3_\pyodbc\
    Complete output (12 lines):
    running install
    running build
    running build_ext
    building 'pyodbc' extension
    creating build
    creating build\temp.win32-3.8
    creating build\temp.win32-3.8\Release
    creating build\temp.win32-3.8\Release\src
    C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.23.28105\bin\HostX86\x86\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -DPYODBC_VERSION=4.0.27 -Ic:\users\macinbox\appdata\local\programs\python\python38-32\include -Ic:\users\macinbox\appdata\local\programs\python\python38-32\include "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.23.28105\include" /EHsc /Tpsrc\buffer.cpp /Fobuild\temp.win32-3.8\Release\src\buffer.obj /Wall /wd4514 /wd4820 /wd4668 /wd4711 /wd4100 /wd4127 /wd4191
    buffer.cpp
    C:\Users\MacInBox\AppData\Local\Temp\pip-install-ysm4ul3_\pyodbc\src\pyodbc.h(19): fatal error C1083: NÆo ‚ poss¡vel abrir arquivo incluir: 'windows.h': No such file or directory
    error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\VC\\Tools\\MSVC\\14.23.28105\\bin\\HostX86\\x86\\cl.exe' failed with exit status 2
    ----------------------------------------
ERROR: Command errored out with exit status 1: 'c:\users\macinbox\appdata\local\programs\python\python38-32\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\MacInBox\\AppData\\Local\\Temp\\pip-install-ysm4ul3_\\pyodbc\\setup.py'"'"'; __file__='"'"'C:\\Users\\MacInBox\\AppData\\Local\\Temp\\pip-install-ysm4ul3_\\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\MacInBox\AppData\Local\Temp\pip-record-fzctfb9u\install-record.txt' --single-version-externally-managed --compile Check the logs for full command output.

Here are the c++ reditribute installed at my pc 这里是 tge b

Currently, pyodbc on PiPI (pyodbc 4.0.27) does not have wheel files for Python 3.8, so when you do pip install pyodbc pip will try to build pyodbc from source. You don't need C++ redistributables for that, you need a C++ compiler .

The next release of pyodbc will almost certainly have pre-compiled wheel files for Python 3.8. In the meantime you can download the required wheel file from

https://www.lfd.uci.edu/~gohlke/pythonlibs/#pyodbc

and then install it with

pip install C:\path\to\pyodbc-4.0.27-cp38-cp38-win32.whl

Update 2020-06-30: Current versions of pyodbc now have wheels for Python 3.8.

Thank you very much. I was using Python 3.10. This did the trick.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM