Combine --user with --prefix error with setup.py install

后端 未结 5 1517
余生分开走
余生分开走 2020-11-30 18:53

I was trying to install Python packages a system I recently gained access to. I was trying to take advantage of Python\'s relatively new per user site-packages directory, an

5条回答
  •  醉话见心
    2020-11-30 19:30

    One time workaround:

    pip install --user --install-option="--prefix=" 
    

    or

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

    Note that there is no text (not even whitespace) after the =.

    Do not forget the --user flag.

    Installing multiple packages:

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

    [install]
    prefix=
    

    Note that there is no text (not even whitespace) after the =.

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

    Finally, remove or rename this file. Leaving this file present will cause issues when installing Python packages system-wide (i.e., without --user) as this user with this ~/.pydistutils.cfg.

    The cause of this issue

    This appears to be an issue with both OpenSUSE and RedHat, which has lead to a bug in virtualenv on these platforms.

    The error stems from a system-level distutils configuration file (in my case /usr/lib64/python2.6/distutils/distutils.cfg) where there was this

    [install]
    prefix=/usr/local
    

    Basically, this is equivalent to always running the install command as install --prefix=/usr/local. You have to override this specification using one of the techniques above.

提交回复
热议问题