ad_ad
ad_ad

Reputation: 385

how does pip find dependencies?

I'm trying to install some packages with pip on a computer where I do not have root access. I'm running into some problems with the dependencies. Basically, I install a package 1:

cd path/to/package1
pip install . --install-option="--prefix=path/to/my/install/dir"

but when I try to install package 2:

cd path/to/package2
pip install . --install-option="--prefix=path/to/my/install/dir"

It cannot find package 1. How do I set the directory where it looks for dependencies?

Upvotes: 0

Views: 662

Answers (2)

ad_ad
ad_ad

Reputation: 385

This doesn't really answer the question but does fix the underlying problem --- installing using

pip install . --user 

installs everything in a local directory that pip knows to look in.

Upvotes: 0

Eugene Lisitsky
Eugene Lisitsky

Reputation: 12845

Try to use virtualenv - it makes package management right.

This way, you first create virtualenv:

 $ virtualenv aaa
 Using base prefix '/Users/el/.pyenv/versions/3.5.1'
 New python executable in /Users/el/tmp/aaa/bin/python3.5
 Also creating executable in /Users/el/tmp/aaa/bin/python
 Installing setuptools, pip, wheel...done.

then

$ source aaa/bin/activate

This sets environment variables and all new installations pip will do in this folder.

When you finish work with it, just do:

$ deactivate

Now you exited from virtualenv to usual "system" one.

As a result:

  • Your environment is isolated from operation system's one
  • You cannot break system libraries
  • You may have have different virtualenvs for different programs. And they may have incompatible together modules
  • You may easily fix modules versions with pip freeze > requirements.txt. Now this file contains all modules with pinned versions in easy format:

    appdirs==1.4.0
    packaging==16.8
    pyparsing==2.1.10
    six==1.10.0
    
  • You may recreate this environment from scratch, just using:

    $ virtualenv folder 
    $ source ./folder/bin/activate
    $ pip install -r requirements.txt
    

Upvotes: 2

Related Questions