9

By default pip installs editable packages into src subdirectory of the directory where Python is installed.

I'd like to install a package from version control to a directory of my choosing using pip's support for checking out a package from source control, for example:

pip install -e git+https://github.com/kennethreitz/requests.git@355b97165c#egg=requests-org

Is this possible?

Kev
  • 118,037
  • 53
  • 300
  • 385
Piotr Dobrogost
  • 41,292
  • 40
  • 236
  • 366
  • Related: [PIP: how do I install a python package into a different directory?](http://stackoverflow.com/q/2915471/95735) – Piotr Dobrogost Jun 02 '12 at 21:52
  • 2
    pip does not install in a directory but in multiple directories. Only if you have a pure python implementation (no scripts/data/binaries) you can talk about a directory of your choosing. Use "--install-option='--install-purelib=/your/lib/path'" in that case. – Anthon Jun 13 '12 at 14:46

1 Answers1

8

pip help install says:

--src=DIR, --source=DIR, --source-dir=DIR, --source-directory=DIR
                      Check out --editable packages into DIR

For example:

pip install -e git+https://github.com/kennethreitz/requests.git@355b97165c#egg=requests-org --source-directory=/tmp

Will install the requests source in /tmp/requests-org

yprez
  • 14,854
  • 11
  • 55
  • 70
  • 1
    Can this be used in `requirements.txt` files as well? I.e. would adding the line `-e git+https://github.com/kennethreitz/requests.git#egg=requests-org --src=/tmp`to such a file work? – Anakhand Jan 05 '21 at 23:54