简体   繁体   English

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

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

I am getting an error when I try to install pyodbc on a Windows computer using 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.

According to that part of the error message:根据错误消息的那部分:

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/

It looks like you are missing a suitable C++ compiler on your platform.您的平台上似乎缺少合适的 C++ 编译器。 According to the documentation of pyodbc you require one:根据 pyodbc 的文档,您需要一个:

Note, pyodbc contains C++ extensions so you will need a suitable C++ compiler on your computer to install pyodbc, for all operating systems.请注意,pyodbc 包含 C++ 扩展,因此您需要在计算机上安装合适的 C++ 编译器来为所有操作系统安装 pyodbc。

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

I suggest using the one form Microsoft Build Tools as suggested in your error message.我建议使用错误消息中建议的一种形式的 Microsoft Build Tools。

pip is trying to compile pyodbc from source but you do not have any compiler installed on your computer. pip正在尝试从源代码编译pyodbc ,但您的计算机上没有安装任何编译器。 There usually are binary packages which do not need to be compiled but there is none for your python version (3.10).通常有不需要编译的二进制包,但您的 python 版本(3.10)没有。

You should either downgrade to an older version of python such as 3.9 or follow the instructions given by the error which is to install the Microsoft Visual C++ compiler.您应该降级到旧版本的 python(例如 3.9)或按照错误给出的说明安装 Microsoft Visual C++ 编译器。

I have uninstalled the python upgrade from python3.10 to python3.9.5 and now I can enjoy using pip without any challenges.我已经卸载了从 python3.10 升级到 python3.9.5 的 python,现在我可以毫无挑战地使用 pip。

暂无
暂无

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

相关问题 安装 scikit-image 时如何解决此错误? - How do i solve this error when installing scikit-image? 当我尝试执行 pip 安装时出现错误 - I get and error when I try to do pip install 当我尝试使用pip install安装此软件包时,如何解决此错误? - How do I fix this error I'm getting when I try to install this package with pip install? 当我在 Django virtualenv 中收到“pip is not识别”错误时,我该如何解决这个问题? - How do I solve the issue when I get “pip isn't recognized” error in Django virtualenv? 当我尝试使用不兼容的 python 版本安装 pip 时,如何获得更好的错误消息? - How do I get a better error message when I try to pip install with an incompatible python version? 当我尝试使用 pip 安装 python 模块时,会导致错误。 我该如何解决? - When I try to install python module using pip, it causes error. How can I fix it? pip 安装 ecapture 产生错误。 我该如何解决这个问题? - pip install ecapture creates an error. How do I solve this? 如何避免使用pip安装tarball时出现“找不到文件”错误? - How do I avoid a file not found error installing a tarball with pip? 当我尝试使用“pip install PyAudio”安装 PyAudio 模块时出现此错误……我现在该怎么办? - I got this error when I try to install the PyAudio module using 'pip install PyAudio'… What should I do now? 尽管安装了 tensorflow,当我尝试从 CMD 运行文件时,出现“ModuleNotFoundError: No module named 'tensorflow'”错误 - Inspite of installing tensorflow, `ModuleNotFoundError: No module named 'tensorflow'` error occurs when I try to run files from CMD
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM