5

I want to set up a Python environment for a whole team and I don't have root access to the server.

I have done a similar thing with Perl and expected to be able to do this for Python in a similar way but I keep running into a problem.

Basically, I want to be able to install a package into /SOME/DIR on the system while ignoring any system wide versions of that package. However, when I run

pip install --install-option="--prefix=/SOME/DIR/" --up --ignore-installed SOME-MODULE 

I keep getting a "permission denied" error because pip keeps trying to remove system-wide packages when upgrading. What does work is this

pip install --user --up --ignore-installed SOME-MODULE 

Which does not try to touch the system-wide packages but it installs the module into a directory in $HOME/.lib, which is not what I need.

It seems impossible to combine --user and a "--prefix" option, so it sems that I can either install into an arbitrary path but then get conflicts with already install system-wide packages or install into my home directory. Neither of them are what I need. For now I have been using the --user option and then moved the installed files across to /SOME/DIR which works but seems odd.

Am I missing something? I have read up on virtualenv but this also doesn't quite sound like what I need. Thanks for your help!

4
  • 5
    In what way does a virtualenv not sound like what you need? Commented Jan 21, 2015 at 17:29
  • This example works for me as far as installing a package to a custom directory - can you provide your specific error message? Commented Jan 21, 2015 at 18:03
  • Yes, it does work when I install a package that isn't yet installed system-wide and none of its dependencies is either. As soon as the package or a dependency is install system-wide you get a conflict because pip insists on trying to remove it even with the --ignore-installed option Commented Jan 22, 2015 at 7:59
  • @MattDMo: virtualenv seems more suited to creating a library of modules for a specific coding project. I want to create an environment for my group to work with Python. We are not developing with Python, just using third party Python scripts. It seems that setting PyTHONPATH in the bashrc and telling pip where to install the packages would be all I need to make this work but pip seems to insist that I can only do this into my own home directory, which I don't understand. Commented Jan 23, 2015 at 11:38

2 Answers 2

2

Note that --install-options is passed directly to the packages setup.py install command - this requires the installation directory to be in your python path. add it to your PYTHONPATH i.e.
set -gx PYTHONPATH $PYTHONPATH '/home/user/temp/lib/python3.4/site-packages'

and run pip

pip install django==1.6 --ignore-installed --install-options="--prefix=/home/user/temp" 

Mostly this is a pain in the ass if you have to do this for each library (note that you will still have potential conflicts with imports if you want to use certain standard libraries from the default site-packages dir, and others from your custom dir). And the best choice is probably, as the comment says, to install virtualenv and virtualenvwrapper

Sign up to request clarification or add additional context in comments.

3 Comments

Thanks. I do have the /SOME/DIR path in my PYTHONPATH and it all seems to be set up correctly because - once I do get the module installed - it is found in that path without a problem. Fair point about the potential conflicts in a mixed module repository.
Have you gotten it to work? (It might be easier to debug by running a setup.py directly, and if that works, pip should work as well)
well, it's working in a sense that I can install into my home directory and then pip ignores the already installed system wide package. Then I have to copy the results into the actual target directory (which is in PYTHONPATH). It seems that the feature to actually ignore the system wide installation only works with the --user option. I'm still puzzled by the use case for the separate --ignore-installed, which doesn't seem to be doing what's on the label
0

I had a similar problem (permission denied + no root access), --build option made it work: pip install --install-option="--prefix=/path/to/local/lib" --build=/tmp wget

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.