title: Heroku tutorial with PIP, virtualenv, psycopg2, Django on Windows 7
body: <p>I've been doing a lot of reading lately about Heroku and I'm thinking about moving over to it.  I thought I would give their little tutorial a try and play around with it a bit.  </p>
  
  <p>Ok.  Time for a confession.  While I have virtualenv installed, I don't really use it.  I'm not a guy that has to switch between different projects very often (e.g. like a contractor my need to do).  I really like the idea of it, but just not that experienced.  I know everyone says that it's best practices these days.  </p>
  
  <p>The problem that I have is that I can't get pip to install psycopg2 (which is a part of the tutorial).  Btw, here's a link to what I'm trying to do (<a href="http://devcenter.heroku.com/articles/django" rel="nofollow">heroku article</a>)</p>
  
  <p>So, this is not a new problem for me.  I've never been able to get the thing to install via pip.  I always get the problem </p>
  
  <blockquote>
    <p>Unable to find vcvarsall.bat</p>
  </blockquote>
  
  <p>The way that I've solved it in the past on a windows machine was to just download the prebuild libs.  If anyone is interested and doesn't know, you can find these <a href="http://www.lfd.uci.edu/~gohlke/pythonlibs/" rel="nofollow">here</a>!  Btw, thank you Christoph Gohlke for maintaining these!!!!</p>
  
  <p>If you search for this vcvarsall.bat error, you will find several posts for it on Stackoverflow.  NONE of them helped me.  I originally tried to go the MingGW route.  After literally 2 nights of effort (and I think I tried every suggestion I could find), I quit trying (right before I threw my PC out the window and went on a kitten-killing rampage).  So, I tried the other route that people suggest - which is to download VC++ 2008 Express edition from Microsoft. Apparently, Python for Windows is built with VC++ 2008 and for some people this is a much easier route than using MinGW.  This seems to have worked much better for me, because I can at least get pip to install it.  But, when I try to import, I get another common problem people seem to have (at least you get hits when you google it).  </p>
  
  <blockquote>
    <p>File "C:\foo\bar\venv\lib\site-packages\psycopg2__init
    __.py", line 67, in 
        from psycopg2._psycopg import BINARY, NUMBER, STRING, DATETIME, ROWID
    ImportError: DLL load failed: The operating system cannot run %1.</p>
  </blockquote>
  
  <p>After some research, it seems like this is a problem with the compiled _psycopg.pyd file trying to link in libpq.dll.  This file is in C:\Program Files (x86)\PostgreSQL\9.1\bin\ - and that is in my path.</p>
  
  <p>So, does anyone know how to fix this?  Or is there a way to get pip to use pyscopg2 that is already successfully installed (via the prebuilt libs) in my site-packages?  Note: I can make the problem go away if I just copy my prebuilt psycopg2 package into the site-packages of the virtual environment.  it will import fine.  However, when you do pip freeze for the requirements for heroku, it's not there.  Is there a way to fake heroku out on this?</p>
  
  <p>Environment is: Windows 7 (64bit), Python 2.6.5, Django 1.3.1, virtualenv 1.6.4, PostgreSQL 9.1, pip 1.0.2</p>