How to install a module for all users with pip on linux?

后端 未结 4 1811
走了就别回头了
走了就别回头了 2020-12-25 10:12

How to install a package in the standard python environment i.e. /usr/local/lib/python2.7/dist-packages using pip and make this new packag

相关标签:
4条回答
  • 2020-12-25 10:35

    Use the --target option when calling pip

    pip install --target=/your/pyinstalldir loremipsum
    

    The target directory must be a location writable by your user.

    Note that this requires the regular user environment has the target directory present in the sys.path. One possible way to achieve that is by using the PYTHONPATH env var:

    # /etc/profile.d/myenvvars.sh
    export PYTHONPATH=/your/pyinstalldir
    
    0 讨论(0)
  • 2020-12-25 10:44

    For Ubuntu 18.04 try sudo -H pip install loremipsum

    0 讨论(0)
  • 2020-12-25 10:49

    With Ubuntu 18.04, using the command sudo pip install stuff-name does not suffice, in my case, in order to install the modules in the global path (it keeps looking at the local-user python path).

    Solution in my case

    I have changed to the root user, and changed directory to its home. Then pip installation worked like expected and installs modules in the global path.

    In detail I followed the nowox answer with a minor change (sudo su, changes to the root user), also see final note about umask 022:

    sudo su
    cd ~
    umask 022
    pip install what-you-like
    

    Note: umask 022 command/row could be optional..., usually umask is already 022, that is the default one.

    0 讨论(0)
  • 2020-12-25 10:55

    You might have a wrong umask set as discussed here

    From your last edit, I guess you umask is set to 027. Try to do

    sudo pip uninstall loremipsum
    umask 022
    sudo pip install loremipsum
    
    0 讨论(0)
提交回复
热议问题