[英]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
.当我尝试使用
cmd
在Windows
计算机上安装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.