29

Have a local package ABC-0.0.2-py3-none-any.whl. I want to install it in the different project through requrements.txt. e.g.

requirements.txt

ABC==0.0.2
Flask==1.1.2
flask-restplus==0.13.0
gunicorn==20.0.4

Is it possible to install the ABC package this way. ABC-0.0.2-py3-none-any.whl is included in source code. I had to pip install ABC-0.0.2-py3-none-any.whl separately.

Innat
  • 16,113
  • 6
  • 53
  • 101
Rajan Sharma
  • 325
  • 1
  • 4
  • 11

3 Answers3

49

This is called a direct reference. Since version 19.3, pip support this in both command line and requirement files. Check out an example from the official documentation.

As to OP's question, simply put the local wheel's relative path, i.e., ./<my_wheel_dir>/<my_wheel.whl>, in requirement.txt, e.g.,

./local_wheels/ABC-0.0.2-py3-none-any.whl
Flask==1.1.2
flask-restplus==0.13.0
gunicorn==20.0.4
chjch
  • 901
  • 9
  • 13
2

With a pyproject.toml file using setuptools the local syntax ./local_wheels/ABC-0.0.2-py3-none-any.whl does not work.

This works:

tensorflow @ file://localhost/pip-wheels/aarch64/tensorflow-2.8.4-cp38-cp38-linux_aarch64.whl

file://localhost/ + absolute paths is needed.

The pip issue migth explain why.

k_o_
  • 5,143
  • 1
  • 34
  • 43
0

in your requirement.txt file add

-f <path to the whl file with file name>==<Version>

then install using python -m pip install -r <path to requirement.txt file>

SiHa
  • 7,830
  • 13
  • 34
  • 43
sahasrara62
  • 10,069
  • 3
  • 29
  • 44
  • 2
    Flat out didn't work. What *does* work is -f == The -f just tells it where to find a candidate wheel... it doesn't actually install anything. – AdamC Feb 17 '22 at 19:25
  • I found == needs to be on its own line as well – jswetzen Apr 21 '23 at 09:11