Cannot install pymssql on windows

2019-04-30 05:00发布

问题:

i am trying to install pymssql as

pip install pymssql

i have windows 7 and python 3.5 (from anaconda) but i get

Failed building wheel for pymssql

i believe its related to freetds and python-dev. how do i install these on windows?

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?

回答1:

I just went through this small bit of hell and finally got things working, here is what I ended up doing:

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.

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).

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.