M. Pierce
M. Pierce

Reputation: 41

Trouble installing pymssql on Windows

I can't find great support for pymssql installation support on Windows. I'm trying to connect to an enterprise database through another employee's python wrapper. This wrapper requires my installing of pymssql. The RTFM on this doesn't have very explicit instructions on the installation process of FreeTDS and OpenSSL.

Steps to Install

All downloaded files (FreeTDS and OpenSSL) are from the RTFM link mentioned above. There is mention of adding both downloads to a C:\Program Files folder and adding the binaries into the system PATH, so I did this:

FreeTDS

  1. Downloaded FreeTDS >> created the directory C:\Program Files (x86)\FreeTDS >> copy/paste contents of FreeTDS download into C:\Program Files (x86)\FreeTDS directory >> added C:\Program Files (x86)\FreeTDS into my system's PATH

Contents of FreeTDS download:

\bin
    \bsqldb.exe
    \bsqldb.exe.manifest
    \bsqlodbc.exe
    ...
    \tsql.exe
\include
    \bkpublic.h
    \cspublic.h
    \cstypes.h
    ...
    \tds_sysdep_public.h
\lib
    \static
        \db-lib.lib
        \iconv.lib
        \libct.lib
        \replacements.lib
        \tds.lib
    \ct.dll
    \ct.dll.manifest
    ...
    \tsodbc.lib
\lib-nossl
(same as \lib)

OpenSSL

  1. Downloaded OpenSSL >> created the directory C:\Program Files (x86)\OpenSSL >> copy/paste contents of OpenSSL download into C:\Program Files (x86)\OpenSSL directory >> added C:\Program Files (x86)\OpenSSL into my system's PATH

Contents of OpenSSL download:

\HashInfo.txt
\libeay32.dll
\OpenSSL License.txt
\openssl.exe
\ReadMe.txt
\ssleay32.dll

PYMSSQL

  1. Install pymssql through pip: python -m pip install pymssql >> then check for install status:

Open Python Environment

Super frustrating. Really appreciate any help here!

(unfortunately most everyone I know runs pymssql from Linux and they don't have this problem)

Upvotes: 4

Views: 5041

Answers (2)

harmonickey
harmonickey

Reputation: 1419

Nowadays I recommend just downloading the version you need from here https://www.lfd.uci.edu/~gohlke/pythonlibs/#pymssql and then installing via below steps.

  1. Download the version to want to place on disk, can be Downloads or anywhere you want. I downloaded pymssql-2.1.4-cp38-cp38-win_amd64.whl because I'm using Python 3.8 on Windows 10 64 bit.
  2. Navigate to directory where you downloaded or move the file...
  3. pip install <pymssql file name>

I didn't have to install anything extra, worked right out of the box.

Upvotes: 3

Gord Thompson
Gord Thompson

Reputation: 123399

As mentioned (briefly) in the pymssql documentation you cited, and also in my related answer here, your Windows PATH needs to include the folder(s) where the DLL files reside, not the base folder(s) for FreeTDS (and OpenSSL, if required).

So, on my test machine running 32-bit Windows my PATH needed to include the "lib-nossl" folder for FreeTDS ...

C:\Users\Gord\Downloads\freetds-v0.95.83-win-x86-vs2015\lib-nossl

... in order for me to use pymssql 2.1.2 with Python 3.5.1 to establish a non-encrypted connection to my SQL Server.

Upvotes: 3

Related Questions