Problems with deploying Heroku Django app from Windows

Deploying Django app to Heroku from Windows machine is little bit tricky.

You can follow instructions in Heroku manual. The first problem that you may encounter is with Postgres support in Python. There is problem with this command:

pip install Django psycopg2 dj-database-url

If you do not have Visual Studio installed on your machine, you’ll receive error that vcvarsall.bat is missing.

Solution is quite easy. You don’t need to install Visaul Studio. Just download binary version of psycopg2 module from http://www.stickpeople.com/projects/python/win-psycopg/

Then you can exclude psycopg2 from pip install command, because it is installed in system directory of Python.

Another tricky issue is with command:

pip freeze >requirements.txt

If you type this command in PowerShell then it will automatically create Unicode file with extra bytes. When you try to deploy project with messed requirements.txt to Herou then you’ll see self explanatory error ;-)

TypeError: must be encoded string without NULL bytes, not str

Nice :-)

Just open requirements.txt file with notepad and select Save as. In Save as dialog choose ANSI.

Commit file and push project to Heroku. It will work ;)

3 Replies to “Problems with deploying Heroku Django app from Windows

  1. I found this article a little too late. It will be very helpful to other Windows users, I had to go through a lot of hassle to figure these out!!

  2. I am still getting this error even after converting to ANSI

    Here is my requirements file:
    dj-database-url==0.3.0
    Django==1.7.7
    gunicorn==19.3.0
    whitenoise==1.0.6
    psycopg2==2.5.4

  3. This solution worked for me as well. If you’re a total n00b like me and it’s still not working remember that you need to commit the changes!

    git commit -m ""

Comments are closed.