1

I'm trying to start a Django app on Heroku using Windows and I'm getting stuck on the following error when I try to pip install psycopg2:

Downloading/unpacking psycopg2
  Downloading psycopg2-2.4.5.tar.gz (719Kb): 719Kb downloaded
  Running setup.py egg_info for package psycopg2

    Error: pg_config executable not found.

    Please add the directory containing pg_config to the PATH
    or specify the full executable path with the option:

        python setup.py build_ext --pg-config /path/to/pg_config build ...

    or with the pg_config option in 'setup.cfg'.
    Complete output from command python setup.py egg_info:
    running egg_info

creating pip-egg-info\psycopg2.egg-info

writing pip-egg-info\psycopg2.egg-info\PKG-INFO

writing top-level names to pip-egg-info\psycopg2.egg-info\top_level.txt

writing dependency_links to pip-egg-info\psycopg2.egg-info\dependency_links.txt

writing manifest file 'pip-egg-info\psycopg2.egg-info\SOURCES.txt'

warning: manifest_maker: standard file '-c' not found

I've googled the error and it seems you need libpq-dev python-dev as dependencies for postgres under Python. I also turned up a link that says you gt into trouble if you don't have the postgres bin folder in your Path so I installed Postgres manually and tried again. This time I get:

error: Unable to find vcvarsall.bat

I am still a python N00b so I am lost. Could someone point me in a general direction?

Cliff
  • 10,586
  • 7
  • 61
  • 102
  • 1
    You can't install psycopg2 via pip on windows (maybe you can if you go through the trouble of setting up a compiler?), the binaries are availalbe at http://www.stickpeople.com/projects/python/win-psycopg/ – monkut Jun 22 '12 at 02:58
  • Really? I just manually installed Postgres for Windows and got around my above error. I'm now stuck on the next error: Unable to find vcvarsall.bat – Cliff Jun 22 '12 at 03:09
  • 1
    I'm pretty sure that error is related to the compiler not existing. – monkut Jun 22 '12 at 03:23
  • Setting up compilation of packages on windows is masochistic, but if that's your pleasure this may help get you started: http://blog.victorjabur.com/2011/06/05/compiling-python-2-7-modules-on-windows-32-and-64-using-msvc-2008-express/ – monkut Jun 22 '12 at 03:28
  • 1
    or use mingw32 http://docs.cython.org/src/tutorial/appendix.html – monkut Jun 22 '12 at 03:29
  • monkut, I think you're right. FWIW I found something that almost looked like it worked here: http://stackoverflow.com/questions/3030984/installing-psycopg2-postgresql-in-virtualenv-on-windows but I have no idea how to verify that it did what I thought it did. I might try mingw next as I have used it in the past. – Cliff Jun 22 '12 at 15:12
  • For what it's worth, it's called Django, not DJango. – airstrike Nov 05 '13 at 14:56
  • Andre, point taken. I've updated the title. – Cliff Nov 06 '13 at 17:34

2 Answers2

1

You can use Cygwin and install all the dependencies, but I went through that issue last week and then I realized it was far easier to use a Virtual Box with Ubuntu as my Guest OS. I still did the development on Windows but used Ubuntu just to communicate/push to heroku

leonsas
  • 4,718
  • 6
  • 43
  • 70
  • Thanks, I'm leaning towards either this or minGW. However I'm wondering how much of all this hassle is truely necessary to set up a basic DJango app on Heroku. Can I just install the dependencies in the main environment? Is there something a lot simpler I could do to get going? – Cliff Jun 22 '12 at 15:14
  • As I said, I just went through the process, mainly because of educational purposes. The most complex, and time consuming part for me was to push the database to the heroku db. They have pretty good documentation so check it out. https://devcenter.heroku.com/articles/django#syncing_the_database – leonsas Jun 22 '12 at 15:27
1

I found the answer to my problem. I believe the problem is that pip is looking to compile the dependency from source. The solution is to find a link to pre-compiled version of the dependency. You can then pass this link to the easyinstall library installed in your virtualenv. Easyinstall will download and install the pre-compiled version of the dependency.

Cliff
  • 10,586
  • 7
  • 61
  • 102