无法在 Windows 上安装 pymssql [英] Cannot install pymssql on windows
问题描述
我正在尝试将 pymssql 安装为
i am trying to install pymssql as
pip install pymssql
我有 Windows 7 和 python 3.5(来自 anaconda)但我得到
i have windows 7 and python 3.5 (from anaconda) but i get
Failed building wheel for pymssql
我相信它与 freetds
和 python-dev
相关.我如何在 Windows 上安装这些?
i believe its related to freetds
and python-dev
. how do i install these on windows?
我需要安装哪些软件包?这个 pip 安装适用于 python 2.7.如果 pip 不起作用,我还有其他方法可以下载和安装 pymssql 吗?
Which packages would i need to install? this pip install worked just fine for python 2.7. If the pip does not work,is there any other way i can download and install pymssql?
推荐答案
我刚刚经历了这小小的地狱,终于开始工作,这是我最终做的:
I just went through this small bit of hell and finally got things working, here is what I ended up doing:
首先找到您的 Python 目录(对我来说是 c:\Python35
),然后按照 PyMSSQL 文档 下载 FreeTDS二进制文件和预编译的OpenSSL二进制文件.Open SSL 二进制文件是在不同版本的 MSVC 中构建的,对我来说,我需要 MSVC 2015 32 位二进制文件(因为我的 Python 副本是 32 位版本).FreeTDS 有点神秘,这里不同的 vs20xx
版本适用于不同代的 Python,在我的情况下 -vs2015
有效,因为我使用的是 Python 3.5,它应该适合你
First locate your Python directory (for me it was c:\Python35
), then following the instructions found on the PyMSSQL documentation download the FreeTDS binaries and the precompiled OpenSSL binaries. Open SSL binaries are built in different versions of MSVC, for me I needed the MSVC 2015 32-bit binaries (because my copy of Python is the 32-bit build). FreeTDS is a little more cryptic, here the different vs20xx
versions work with different generations of Python, in my case -vs2015
worked because I am using Python 3.5 which should work for you as well.
接下来从 OpenSSL 版本中的 '/bin' 目录和 FreeTDS 版本中的 /lib
目录中提取 dll 到一个文件夹中(在我的例子中,我使用了 c:\Python35\FreeTDS
).
Next extract the dlls from the '/bin' directory in the OpenSSL release and the /lib
directory in the FreeTDS release into a folder (in my case I used c:\Python35\FreeTDS
).
最后将此文件夹添加到您的系统PATH
.您现在可以运行 import pymssql
而不会收到任何错误.在 Windows 上,您还可以创建位于 C:\freetds 的 配置文件.conf
可以提供一些全局设置,使您的 python 脚本清除任何连接字符串.
Finally add this folder to your system PATH
. You can now run import pymssql
and not receive any errors. On windows you can also create a config file located at C:\freetds.conf
which can provide some global settings to keep your python scripts clear of any connection strings.
这篇关于无法在 Windows 上安装 pymssql的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!