pipenv: pipenv cannot install psycopg2-binary, but pip can (py 3.8)

Issue description

I’m trying to bring a project using requirements.txt into using Pipfile. I am stumped by the fact that pipfile cannot install psycopg2-binary, but pip can. I’m using windows, and developers will not generally be simply able to build psycopg2 from sources.

Problem:

Create a pipenv using Python 3.8 calling pipfile install psycopg2-binary

Expected result

I’ll expect it to be installed to the virtualenv.

Actual result

We get the error

 raise InstallationError(
pipenv.patched.notpip._internal.exceptions.InstallationError: Command "python setup.py egg_info" failed with error code 1 in C:\Users\kristjan\AppData\Local\Temp\tmp1wcw4j8zbuild\psycopg2-binary\

workaround:

calling pipenv run pip install psycopg2-binary results in the package being installed. But this is not adequate, because it means that Pipfile and Pipfile.lock can not be used to deploy the application any more.

Steps to replicate

On windows:

pipenv --python 3.8
pipenv install psycopg2-binary

Other

I am aware that psycopg2-binary is not considered optimal for production. However, for development on windows that is the only practical way to bring the driver in for regular users. I would be happy to have a separate requirement if running on linux with suitable prerequisites installed.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 6
  • Comments: 26 (2 by maintainers)

Most upvoted comments

Please don’t avoid this issue by closing it! The fact that pip (an inferior tool) can do this out-of-the-box while PipEnv cannot is a big pain point, especially considering the fact that a lot of beginner tutorials teach using “deploy to heroku with postgres” where this bug breaks everything and is off-putting for new learners (and potentially new users of pipenv).

For anyone continuing to run into this issue, go ahead and try using the new prerelease of pipenv (i.e. pip install --upgrade --pre pipenv) & make sure you have postgres client binaries installed (i.e. via sudo apt install libpq-dev on ubuntu/debian for the minimal headers). I confirmed this on a fresh container and could not reproduce the issue with the headers installed. Without the headers, I saw a rather long error message, at the top of which I was instructed to install them.

Closing for now, please file a new issue if the pre-release + installing appropriate client binaries or headers does not resolve this. Thanks!

Python3.8, pipenv==2022.3.28, and Ubuntu, issue still exists

@yelled1 nvm 😃

@kristjanvalur I have a new snippet which fails:

pipenv --python 3.8
pipenv install "psycopg2-binary==2.7.7"

This one works fine without errors for me:

pipenv --python 3.8
pipenv install psycopg2-binary

So maybe when this issue was filled, there was no psycopg2-binary wheel for python 3.8? As there is no python3.8 wheel for psycopg2-biary==2.7.7? https://pypi.org/project/psycopg2-binary/2.7.7/#files (no 2.7.7 wheel for py3.8)

As for TODAY, if you have no cached psycopg2-binary, python 3.8 + psycopg2-binary>=2.8.4 should be fine: https://pypi.org/project/psycopg2-binary/2.8.4/#files

Edit: Note that windows wheel have later date (Nov 10, 2019) than many-linux ones.

Same problem here using linux.

Only works when I use --sequential flag