Meritor
Meritor

Reputation: 166

pip install private package from local with external dependency

I am using pip to install a few private packages in a virtual environment. Using python version 3.7.3 and pip version 18.1

I have copied the .whl file of that private package to a local directory. Now that package has external dependencies whith another private packages and also public packages.

By Public Package I meant the package that is available from public repositories (pypi or piwheels).

I have tried using

pip install my-private-package -f /path/to/private/package/directory

Now, this is failing with below message:

Could not install packages due to an EnvironmentError: 404 Client Error: Not Found for url: https://pypi.org/simple/my_private_package

Then I have tried below two command (expecting this would fail)

pip install -f /path/to/private/package/directory --no-index

and

pip install --no-index --find-links=/path/to/private/package/directory private-package  --extra-index-url https://pypi.org/simple --extra-index-url  https://www.piwheels.org/simple

and those failed as expected with same error message

Could not find a version that satisfies the requirement public-package==x.x.x (from private-package->another-private-package) (from versions: )

I also tried

pip install /path/to/private/package/directory/private_package_x_x_x.whl

This failed too with below error message. Which means that another private package could not be found in public repository. This is obvious.

Could not install packages due to an EnvironmentError: 404 Client Error: Not Found for url: https://pypi.org/simple/another-private-package/

So the last attempt that was tried:

pip install /path/to/private/package/directory/private_package_x_x_x.whl --find-links=/path/to/private/package/directory

Unfortunately, no luck this time too.

I can think of a couple of workarounds:

  1. Download all the dependencies and keep it in the local directory (/path/to/private/package/directory)
  2. Create a private server and provide index information over http

Now, not happy with option 1 as I have to download every time a new public dependency is added. Option 2 may be a good option - I may go with it, if no other option is found.

Any input suggestion will be greatly appreciated.

Update:

OS: debian 10 python version 3.7.3 and pip version 18.1

This works on Windows with python 3.9 and PIP 21.1.2 , i.e pip install my-private-package -f C:\path\to\private\package\directory

Upvotes: 0

Views: 1259

Answers (1)

Meritor
Meritor

Reputation: 166

Thanks for the direction @Matteo Zanoni. The problem was the version. The --find-link works when I upgraded pip from 18.1 to 21.3.1

Upvotes: 1

Related Questions