title: How to compile and install pysqlcipher for python 2.7 on Windows 7
body: <p>I have recently installed Python 2.7 on Windows 7. I have also installed setuptools and pip for python, MinGW, <a href="http://www.microsoft.com/en-us/download/details.aspx?id=44266" rel="nofollow">Visual C++ for Python</a>, and OpenSSL over the course of my trials. All have entries in my %PATH% and I have the environment variables VS90COMNTOOLS and VS100COMNTOOLS pointing to "C:\Users\username\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\bin".</p>
  
  <p>I have tried several different ways to install this. I will outline each below. (all of there were run from an elevated command prompt.)</p>
  
  <ol>
  <li><p>Download source and compile.</p>
  
  <p>python setup.py install</p></li>
  </ol>
  
  <p>This gives the output:</p>
  
  <pre><code>running install
  running build
  running build_py
  running build_ext
  building 'pysqlcipher._sqlite' extension
  error: Unable to find vcvarsall.bat
  </code></pre>
  
  <ol start="2">
  <li>Compile source using MinGW</li>
  </ol>
  
  <p>Since after installing VS for Python I still got the same error, I decided to try:</p>
  
  <pre><code>setup.py install build --compiler=mingw32
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>running install
  running build
  running build_py
  running build_ext
  building 'pysqlcipher._sqlite' extension
  D:\Developer\MinGW\bin\gcc.exe -mdll -O -Wall -DMODULE_NAME=\"pysqlcipher.dbapi2\" -DSQLITE_ENABLE_FTS3=1 -DSQLITE_ENABL
  E_RTREE=1 -DSQLITE_ENABLE_LOAD_EXTENSION=1 -DSQLITE_HAS_CODEC=1 -DSQLITE_TEMP_STORE=2 -Iamalgamation -ID:\Developer\Pyth
  on27\include -ID:\Developer\Python27\PC -c src/module.c -o build\temp.win32-2.7\Release\src\module.o
  D:\Developer\MinGW\bin\gcc.exe -mdll -O -Wall -DMODULE_NAME=\"pysqlcipher.dbapi2\" -DSQLITE_ENABLE_FTS3=1 -DSQLITE_ENABL
  E_RTREE=1 -DSQLITE_ENABLE_LOAD_EXTENSION=1 -DSQLITE_HAS_CODEC=1 -DSQLITE_TEMP_STORE=2 -Iamalgamation -ID:\Developer\Pyth
  on27\include -ID:\Developer\Python27\PC -c src/connection.c -o build\temp.win32-2.7\Release\src\connection.o
  src/connection.c: In function '_pysqlite_final_callback':
  src/connection.c:787:15: warning: variable 'aggregate_class' set but not used [-Wunused-but-set-variable]
       PyObject* aggregate_class;
                 ^
  D:\Developer\MinGW\bin\gcc.exe -mdll -O -Wall -DMODULE_NAME=\"pysqlcipher.dbapi2\" -DSQLITE_ENABLE_FTS3=1 -DSQLITE_ENABL
  E_RTREE=1 -DSQLITE_ENABLE_LOAD_EXTENSION=1 -DSQLITE_HAS_CODEC=1 -DSQLITE_TEMP_STORE=2 -Iamalgamation -ID:\Developer\Pyth
  on27\include -ID:\Developer\Python27\PC -c src/cursor.c -o build\temp.win32-2.7\Release\src\cursor.o
  src/cursor.c: In function 'pysqlite_cursor_dealloc':
  src/cursor.c:129:9: warning: variable 'rc' set but not used [-Wunused-but-set-variable]
       int rc;
           ^
  D:\Developer\MinGW\bin\gcc.exe -mdll -O -Wall -DMODULE_NAME=\"pysqlcipher.dbapi2\" -DSQLITE_ENABLE_FTS3=1 -DSQLITE_ENABL
  E_RTREE=1 -DSQLITE_ENABLE_LOAD_EXTENSION=1 -DSQLITE_HAS_CODEC=1 -DSQLITE_TEMP_STORE=2 -Iamalgamation -ID:\Developer\Pyth
  on27\include -ID:\Developer\Python27\PC -c src/cache.c -o build\temp.win32-2.7\Release\src\cache.o
  D:\Developer\MinGW\bin\gcc.exe -mdll -O -Wall -DMODULE_NAME=\"pysqlcipher.dbapi2\" -DSQLITE_ENABLE_FTS3=1 -DSQLITE_ENABL
  E_RTREE=1 -DSQLITE_ENABLE_LOAD_EXTENSION=1 -DSQLITE_HAS_CODEC=1 -DSQLITE_TEMP_STORE=2 -Iamalgamation -ID:\Developer\Pyth
  on27\include -ID:\Developer\Python27\PC -c src/microprotocols.c -o build\temp.win32-2.7\Release\src\microprotocols.o
  D:\Developer\MinGW\bin\gcc.exe -mdll -O -Wall -DMODULE_NAME=\"pysqlcipher.dbapi2\" -DSQLITE_ENABLE_FTS3=1 -DSQLITE_ENABL
  E_RTREE=1 -DSQLITE_ENABLE_LOAD_EXTENSION=1 -DSQLITE_HAS_CODEC=1 -DSQLITE_TEMP_STORE=2 -Iamalgamation -ID:\Developer\Pyth
  on27\include -ID:\Developer\Python27\PC -c src/prepare_protocol.c -o build\temp.win32-2.7\Release\src\prepare_protocol.o
  
  D:\Developer\MinGW\bin\gcc.exe -mdll -O -Wall -DMODULE_NAME=\"pysqlcipher.dbapi2\" -DSQLITE_ENABLE_FTS3=1 -DSQLITE_ENABL
  E_RTREE=1 -DSQLITE_ENABLE_LOAD_EXTENSION=1 -DSQLITE_HAS_CODEC=1 -DSQLITE_TEMP_STORE=2 -Iamalgamation -ID:\Developer\Pyth
  on27\include -ID:\Developer\Python27\PC -c src/statement.c -o build\temp.win32-2.7\Release\src\statement.o
  src/statement.c: In function 'pysqlite_statement_dealloc':
  src/statement.c:408:9: warning: variable 'rc' set but not used [-Wunused-but-set-variable]
       int rc;
           ^
  D:\Developer\MinGW\bin\gcc.exe -mdll -O -Wall -DMODULE_NAME=\"pysqlcipher.dbapi2\" -DSQLITE_ENABLE_FTS3=1 -DSQLITE_ENABL
  E_RTREE=1 -DSQLITE_ENABLE_LOAD_EXTENSION=1 -DSQLITE_HAS_CODEC=1 -DSQLITE_TEMP_STORE=2 -Iamalgamation -ID:\Developer\Pyth
  on27\include -ID:\Developer\Python27\PC -c src/util.c -o build\temp.win32-2.7\Release\src\util.o
  D:\Developer\MinGW\bin\gcc.exe -mdll -O -Wall -DMODULE_NAME=\"pysqlcipher.dbapi2\" -DSQLITE_ENABLE_FTS3=1 -DSQLITE_ENABL
  E_RTREE=1 -DSQLITE_ENABLE_LOAD_EXTENSION=1 -DSQLITE_HAS_CODEC=1 -DSQLITE_TEMP_STORE=2 -Iamalgamation -ID:\Developer\Pyth
  on27\include -ID:\Developer\Python27\PC -c src/row.c -o build\temp.win32-2.7\Release\src\row.o
  D:\Developer\MinGW\bin\gcc.exe -mdll -O -Wall -DMODULE_NAME=\"pysqlcipher.dbapi2\" -DSQLITE_ENABLE_FTS3=1 -DSQLITE_ENABL
  E_RTREE=1 -DSQLITE_ENABLE_LOAD_EXTENSION=1 -DSQLITE_HAS_CODEC=1 -DSQLITE_TEMP_STORE=2 -Iamalgamation -ID:\Developer\Pyth
  on27\include -ID:\Developer\Python27\PC -c amalgamation\sqlite3.c -o build\temp.win32-2.7\Release\amalgamation\sqlite3.o
  
  amalgamation\sqlite3.c:13654:26: fatal error: openssl/rand.h: No such file or directory
   #include &lt;openssl/rand.h&gt;
                            ^
  compilation terminated.
  error: command 'D:\\Developer\\MinGW\\bin\\gcc.exe' failed with exit status 1
  </code></pre>
  
  <ol start="3">
  <li><p>I installed OpenSSL and tried again. Still the same output. I also installed pyopenssl. Still the same error.</p></li>
  <li><p>I tried going the easy way: </p>
  
  <p>easy_install pysqlcipher</p>
  
  <p>pip install pysqlcipher</p></li>
  </ol>
  
  <p>These also complain about not being able to find 'openssl/rand.h'</p>
  
  <p>Does anyone have any ideas how to resolve this so I can compile this package for Windows?
  Thanks!</p>