Installing pymssql on Windows server
<p>I need to run Python with the pymssql library to query SQL server and I spent a day installing and compiling stuff on Windows.</p>

<p>Installation of pymssql was very painful, until I developed this procedure:</p>

<ul>
<li>install python</li>
<li>update pip</li>
<li>download OpenSSL from <a href="http://www.npcglib.org/~stathis/blog/precompiled-openssl/" rel="nofollow noreferrer">http://www.npcglib.org/~stathis/blog/precompiled-openssl/</a></li>
<li>add bin folder to Path environment variable</li>
<li>download FreeTDS from <a href="https://github.com/ramiro/freetds/releases" rel="nofollow noreferrer">https://github.com/ramiro/freetds/releases</a></li>
<li>add lib folder to Path environment variable</li>
<li>pip install pymssql</li>
</ul>

<p>I even created the .exe package, so I won't have to install all this on live machine. It worked OK. Executable also worked on some other Windows machine.</p>

<p>But, when I tried it on the server it didn't work for some reason. The error didn't make sense and I started to cry:</p>

<blockquote>
  <p>WindowsError: [Error -2146893795] Provider DLL failed to initialize correctly</p>
</blockquote>

<p>Could not help myself with links like this one: </p>

<p><a href="https://stackoverflow.com/questions/21791005/windows-error-provider-dll-failed-to-initialize-correctly-on-import-of-cgi-mo/34370644#comment62922523_34370644">&quot;Windows Error: provider DLL failed to initialize correctly&quot; on import of cgi module in frozen wxpython app</a></p>

<p>I have hundreds of tabs opened in my browser and I think I've searched the entire Internet.</p>

<p>I decided I'd try the Python and pymssql installation on the server, which I wanted to avoid, but let's go. And of course my frustration didn't end here. After successful installation I still can't load pymssql:</p>

<pre class="lang-none prettyprint-override"><code>C:\Users\Me&gt;C:\Python27\python.exe
Python 2.7.11 (v2.7.11:6d1b6a68f775, Dec  5 2015, 20:40:30) [MSC v.1500 64 bit (
AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
&gt;&gt;&gt; import time
&gt;&gt;&gt; import sys
&gt;&gt;&gt; import pymssql
Traceback (most recent call last):
  File "&lt;stdin&gt;", line 1, in &lt;module&gt;
ImportError: DLL load failed: %1 is not a valid Win32 application.
</code></pre>

<p>Can anyone point out where I went wrong?</p>