Combination - user with --prefix error with setup.py installation

I tried to install Python packages on a system that I recently accessed. I tried to use Python relatively new to the directory of custom package sites and a new option --user . (The option is currently undocumented , however it exists for Python 2.6+, you can see the help by running python setup.py install --help .)

When I tried to run

 python setup.py install --user 

on any package I downloaded, I always got the following error:

 error: can't combine user with with prefix/exec_prefix/home or install_(plat)base 

The error was extremely puzzled because, as you can see, I did not provide the --prefix , --exec-prefix , --install-base or --install-platbase as command line options. I spent a lot of time figuring out what the problem is. I document my answer below, hoping to rid another poor soul of a few hours of shaving a yak .

+72
python installation distutils
Dec 20 '10 at 23:54
source share
2 answers

One-time Bypass:

 pip install --user --install-option="--prefix=" <package_name> 

or

 python setup.py install --user --prefix= 

Please note that after = there is no text (even without spaces).

Do not forget the --user flag.

Installing multiple packages:

Create ~/.pydistutils.cfg (or the equivalent for your OS / platform) with the following contents:

 [install] prefix= 

Please note that after = there is no text (even without spaces).

Then run the necessary pip install --user or python setup.py install --user . Do not forget the --user flag.

Finally, delete or rename this file. If you leave this file, it will cause problems when installing Python packages in system-wide mode (i.e. Without --user ) as this user with this ~/.pydistutils.cfg .

Reason for this problem

This seems to be a problem with OpenSUSE and RedHat, which led to a virtualenv error on these platforms.

The error is related to the distutils configuration file at the system level (in my case /usr/lib64/python2.6/distutils/distutils.cfg ), where was this

 [install] prefix=/usr/local 

Basically, this is equivalent to always having the install command run as install --prefix=/usr/local . You must override this specification using one of the above methods.

+119
Dec 21 2018-10-12T00:
source share

As noted in the comments, the accepted answer (by @gotgenes, which supposedly has genes) can lead to unexpected consequences.

@rogeleaderr says: "Note that saving this file like this will make Python think that / is your python library root directory, which leads to confusing issues if you try to install other new packages."

Instead of writing a new configuration file, as @gotgenes recommends, it is better to add --prefix= (without text to the right of the equal sign) as an option on the command line, as in

 $ python setup.py install --user --prefix= 
+3
May 05 '15 at 6:18
source share



All Articles