Search code examples
pythonherokupsycopg2heroku-postgres

Heroku does not install psycopg2 from Pipfile


I have a very simple Flask Python app with this Pipfile. The Pipfile includes "psycopg2" = "*". The app can conntect to the PostgreSQL database when started locally. However it fails on Heroku. It seems Heroku does not install psycopg2 for whatever reasons. I've catpured the logs from a Heroku deployment here.

Would anyone know where to look first? Should I rather switched back to a requirements file? Also, why is yapf installed when it's a dev dependency?


Solution

  • Your Heroku build output shows requirements being installed from requirements.txt and makes no mention of Pipfile or Pipfile.lock. It isn't clear from Heroku's documentation, but I suspect that requirements.txt takes precedence over Pipfile / Pipfile.lock if both are present.

    Remove your requirements.txt file, commit the change, and push back to Heroku, e.g.

    git rm requirements.txt
    git commit -m "Remove obsolete requirements.txt"
    git push heroku
    

    Note that this also explains why yapf is being installed: it's in your requirements.txt file.