package is installed via pip in wrong (src) directory instead of site packages
Asked Answered
M

1

17

I'm installing this package into a virtualenv using virtualenvwrapper and pip with this command:

pip install -e git+git://github.com/mr-stateradio/django-exchange.git#egg=django_exchange-master

Interestingly the package is then placed into a src folder, and not into the site-packages folder which I would have expected. The package is placed into this folder:

<path-to-my-virtual-env>/testenv/src/django-exchange-master/exchange

Instead of this:

<path-to-my-virtual-env>/testenv/lib/python2.7/site-packages

I assume something is wrong with the pip install command I'm using or with the setup.py of the package.

Mealie answered 28/5, 2013 at 6:35 Comment(1)
LoL. Stackoverflow is really an amazing place. The details in your question help me solved the same problem that troubled me for hours.Entomology
E
25

The -e option tells pip to install packages in “editable” mode. If you remove the -e option, pip will install the package into <venv path>/lib/Python_version/site-packages. Don't forget to remove the packages inside <venv path>/src, because python looks for the packages inside <venv path>/src first.

pip supports installing from Git, Mercurial, Subversion and Bazaar, and detects the type of VCS using url prefixes: “git+”, “hg+”, “bzr+”, “svn+”.

e.g

$ pip install -e git+https://git.repo/some_pkg.git#egg=SomePackage          # from git
$ pip install -e hg+https://hg.repo/some_pkg.git#egg=SomePackage            # from mercurial
$ pip install -e svn+svn://svn.repo/some_pkg/trunk/#egg=SomePackage         # from svn
$ pip install -e git+https://git.repo/some_pkg.git@feature#egg=SomePackage  # from 'feature' branch

VCS projects can be installed in editable mode (using the –editable option) or not.

  • For editable installs, the clone location by default is <venv path>/src/SomeProject in virtual environments, and <cwd>/src/SomeProject for global installs. The –src option can be used to modify this location.
  • For non-editable installs, the project is built locally in a temp dir and then installed normally. `
Entomology answered 12/12, 2013 at 16:0 Comment(2)
Should be --src in pip I think? pip install -r ./requirements.txt --no-cache --src ~/.virtualenvs/PROJECTNAME/srcMarcellamarcelle
This is right, but when installing the package from a requirements.txt file, if you remove the -e option and the URL is like git://github.com/ORG/PACKAGE.git@TAG#egg=PACKAGE it will fail with ERROR: Invalid requirement log, and prepending the -e argument in the requirements.txt solves the problem but with the inconvenience of having the package in the src/ folder. Solution: instead of prefixing the URL with just git://, it has to be git+git://.Featheredge

© 2022 - 2024 — McMap. All rights reserved.