繁体   English   中英

当我尝试在 cmd 中使用 pip 安装 pyodbc 时,如何解决错误上升

[英]How do I solve an error rising when I try installing pyodbc using pip in cmd

当我尝试使用cmdWindows计算机上安装pyodbc时出现错误。

C:\Users\Pcyber\AppData\Local\Programs\Python\Python310>python.exe -m 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\Pcyber\AppData\Local\Programs\Python\Python310\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Pcyber\\AppData\\Local\\Temp\\pip-install-w2t0bax7\\pyodbc_0972efc851a7442b9e86edce259cfc8a\\setup.py'"'"'; __file__='"'"'C:\\Users\\Pcyber\\AppData\\Local\\Temp\\pip-install-w2t0bax7\\pyodbc_0972efc851a7442b9e86edce259cfc8a\\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\Pcyber\AppData\Local\Temp\pip-record-xbgtptdk\install-record.txt' --single-version-externally-managed --compile --install-headers 'C:\Users\Pcyber\AppData\Local\Programs\Python\Python310\Include\pyodbc'
         cwd: C:\Users\Pcyber\AppData\Local\Temp\pip-install-w2t0bax7\pyodbc_0972efc851a7442b9e86edce259cfc8a\
    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/
    ----------------------------------------
ERROR: Command errored out with exit status 1: 'C:\Users\Pcyber\AppData\Local\Programs\Python\Python310\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Pcyber\\AppData\\Local\\Temp\\pip-install-w2t0bax7\\pyodbc_0972efc851a7442b9e86edce259cfc8a\\setup.py'"'"'; __file__='"'"'C:\\Users\\Pcyber\\AppData\\Local\\Temp\\pip-install-w2t0bax7\\pyodbc_0972efc851a7442b9e86edce259cfc8a\\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\Pcyber\AppData\Local\Temp\pip-record-xbgtptdk\install-record.txt' --single-version-externally-managed --compile --install-headers 'C:\Users\Pcyber\AppData\Local\Programs\Python\Python310\Include\pyodbc' Check the logs for full command output.

根据错误消息的那部分:

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/

您的平台上似乎缺少合适的 C++ 编译器。 根据 pyodbc 的文档,您需要一个:

请注意,pyodbc 包含 C++ 扩展,因此您需要在计算机上安装合适的 C++ 编译器来为所有操作系统安装 pyodbc。

见这里: https://pypi.org/project/pyodbc/

我建议使用错误消息中建议的一种形式的 Microsoft Build Tools。

pip正在尝试从源代码编译pyodbc ,但您的计算机上没有安装任何编译器。 通常有不需要编译的二进制包,但您的 python 版本(3.10)没有。

您应该降级到旧版本的 python(例如 3.9)或按照错误给出的说明安装 Microsoft Visual C++ 编译器。

我已经卸载了从 python3.10 升级到 python3.9.5 的 python,现在我可以毫无挑战地使用 pip。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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