Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

python, change user site directory or install setup.py --prefix with --user

I'd want to install python modules as non-root user like this

$ pip install -I --install-option="--prefix=~/usr" scipy

Unfortunately this usually does not work unless you specify --user. But --user can't be used together with --prefix. Using --user only (without --prefix) installs to ~/.local which I find ugly because I have a well maintained ~/usr and don't want to add even more stuff to my env to make ~/.local usable too.

So my questions:

  1. How can I let --prefix and --user work together for setup.py or how else could setup.py succeed without using --user?
  2. Or can I change the user site directory from ~/.local to ~/usr somehow by env?
like image 529
rudimeier Avatar asked Jun 25 '14 23:06

rudimeier


People also ask

How do I change the path of a Python site package?

The easiest way to change it is to add a file /usr/local/lib/python2. 6/dist-packages/site-packages. pth containing ../site-packages . Alternatively, maybe you can teach the package to use site.

Where do I install Python setup py?

Installing Python Packages with Setup.py To install a package that includes a setup.py file, open a command or terminal window and: cd into the root directory where setup.py is located. Enter: python setup.py install.

Is setup py install deprecated?

...as of the last few years all direct invocations of setup.py are effectively deprecated in favor of invocations via purpose-built and/or standards-based CLI tools like pip, build and tox.

How do I change Python setup?

To permanently modify the default environment variables, click Start and search for 'edit environment variables', or open System properties, Advanced system settings and click the Environment Variables button. In this dialog, you can add or modify User and System variables.


1 Answers

To answer your first question:

In Installing Python Modules guide written by Greg Ward we read:

Note that the various alternate installation schemes are mutually exclusive: you can pass --user, or --home, or --prefix and --exec-prefix, or --install-base and --install-platbase, but you can’t mix from these groups.

To answer your second question:

In the same guide there's section Alternate installation: the user scheme where we read:

Files will be installed into subdirectories of site.USER_BASE

with site.USER_BASE linked to https://docs.python.org/2/library/site.html#site.USER_BASE. There we are asked to see also information on PYTHONUSERBASE environment variable:

Defines the user base directory, which is used to compute the path of the user site-packages directory and Distutils installation paths for python setup.py install --user.

Also, you might be interested in the home scheme:

The idea behind the “home scheme” is that you build and maintain a personal stash of Python modules. This scheme’s name is derived from the idea of a “home” directory on Unix, since it’s not unusual for a Unix user to make their home directory have a layout similar to /usr/ or /usr/local/.

like image 197
Piotr Dobrogost Avatar answered Nov 14 '22 22:11

Piotr Dobrogost