【问题标题】:How can I install pyodbc on Windows for use with Python 3.8?如何在 Windows 上安装 pyodbc 以与 Python 3.8 一起使用?
【发布时间】:2020-03-15 07:31:50
【问题描述】:

我在安装 pyodbc 时遇到错误,我正在研究这个问题,可能是 c++ 重新分发安装问题,但即使使用 c++ 重新分发安装更新了问题 oc

尝试安装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.

这是安装在我的电脑上的 c++ reditribute

【问题讨论】:

    标签: python python-3.x pyodbc


    【解决方案1】:

    目前,PiPI (pyodbc 4.0.27) 上的 pyodbc 没有适用于 Python 3.8 的轮文件,因此当您这样做时,pip install pyodbc pip 将尝试从源代码构建 pyodbc。你不需要 C++ redistributables,你需要一个 C++ 编译器

    pyodbc 的下一个版本几乎肯定会为 Python 3.8 预编译轮子文件。同时,您可以从

    下载所需的轮子文件

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

    然后安装它

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

    2020-06-30 更新:当前版本的 pyodbc 现在有适用于 Python 3.8 的轮子。

    【讨论】:

    • 嘿嘿!!!谢谢!!!!我已经下载并尝试使用 pip install C:\path\to\with pyodbc‑4.0.27‑cp38‑cp38‑win32.whl 并解决了问题!谢谢!!!
    • 我已经连续搜索了将近 3 个小时。 pyodbc 应该更新它的资源。
    猜你喜欢
    • 2018-09-03
    • 2015-11-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-02-29
    • 2014-01-25
    • 1970-01-01
    • 2023-04-10
    相关资源
    最近更新 更多