[英]Installing pyodbc for Python 3.7 on Windows
I am a newbie to python and I need to connect to SQL Server.我是 python 的新手,我需要连接到 SQL Server。 I run the following command in my DB_Connect.py file.
我在 DB_Connect.py 文件中运行以下命令。 I run python DB_Connect.py from CMD line and it gives error on
import pyodbc
.我从 CMD 行运行 python DB_Connect.py ,它在
import pyodbc
出错。
I then I ran command pip install pyodbc
but it give an error saying, "Microsoft Visual C++ 14.0 is required".然后我运行命令
pip install pyodbc
但它给出了一个错误,说“需要 Microsoft Visual C++ 14.0”。 I installed "Microsoft Visual C++ 2015 Redistributable" to accommodate this because I would need to get a license for a full version.我安装了“Microsoft Visual C++ 2015 Redistributable”来适应这一点,因为我需要获得完整版本的许可证。 My understanding is that this will work.
我的理解是这会奏效。 I still get this error:
我仍然收到此错误:
Pic of pip install pyodbc err pip install pyodbc err 的图片
Do I need to install a full version of Visual C++ or is there a free option?我需要安装完整版的 Visual C++ 还是有免费选项? Why doesnt this CMD work with the Redistributable version?
为什么这个 CMD 不适用于 Redistributable 版本? How do I get past this step?
我如何通过这一步?
PC: windows 7 pro - 64 Python Version: 3.7.0 PC:windows 7 pro - 64 Python 版本:3.7.0
Update 2018-08-15更新 2018-08-15
pyodbc 4.0.24, released today, now includes Python 3.7 wheels for installing on Windows and Mac via pip
.今天发布的 pyodbc 4.0.24 现在包含 Python 3.7 轮子,可通过
pip
安装在 Windows 和 Mac 上。
pyodbc wheel files for Python 3.7 are not yet available on PyPI . Python 3.7 的 pyodbc 轮文件在PyPI上尚不可用。 They have been requested via the GitHub issue here .
他们是通过此处的 GitHub 问题请求的。
You could always revert to Python 3.6 for the time being.您暂时可以随时恢复到 Python 3.6。 Or, if you really need Python 3.7 right now then you'll have to install the required Visual Studio components so
pip
can build pyodbc from source.或者,如果您现在确实需要Python 3.7,那么您必须安装所需的 Visual Studio 组件,以便
pip
可以从源代码构建 pyodbc。 Details here .详情请看这里。
I then I ran command pip install pyodbc but it give an error saying, "Microsoft Visual C++ 14.0 is required".
然后我运行命令 pip install pyodbc 但它给出了一个错误,说“需要 Microsoft Visual C++ 14.0”。 I installed "Microsoft Visual C++ 2015 Redistributable" to accommodate this
我安装了“Microsoft Visual C++ 2015 Redistributable”来适应这个
That didn't work because you installed the runtime support for Visual C++.这不起作用,因为您安装了 Visual C++ 的运行时支持。 You need the build tools for Visual C++, described here .
您需要 Visual C++ 的构建工具,此处描述。
This solution worked for me:这个解决方案对我有用:
pip install --only-binary :all: pyodbc
More about above: Microsoft Visual C++ 14.0 is required (Unable to find vcvarsall.bat)以上更多信息:需要Microsoft Visual C++ 14.0(无法找到 vcvarsall.bat)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.