Search code examples
pythonpippsycopg2

Error when pip installing package requiring psycopg2-binary


I have a python package whose setup.py declares a dependency to psycopg2-binary package (among others) :

install_requires=['psycopg2-binary==2.9.9', ...]

I get the following error when trying to install it in my virtual environment :

Command

pip install --index-url https://some-region.pkg.dev/myproject/mypackage/simple/ mypackage

Error

ERROR: Could not find a version that satisfies the requirement psycopg2-binary==2.9.9 (from mypackage) (from versions: none)
ERROR: No matching distribution found for psycopg2-binary==2.9.9

However, there's no error when installing psycopg2-binary manually :

pip install psycopg2-binary==2.9.9

Once psycopg2-binary is installed I can install my package (same command as above) without any issue.

Question

Is it possible to install my package without having to install psycopg2(-binary) beforehand (I don't seem to have issues with the other required packages) ?


Solution

  • You provided --index-url that doesn't have psycopg2-binary so pip cannot install it. You need to give a few indices to install from:

    pip install --index-url https://some-region.pkg.dev/myproject/mypackage/simple/ --extra-index-url https://pypi.org/simple mypackage
    

    Then pip will install from 2 indices.