I'm wondering if there is a standard way to install python applications with pip (without using sudo) to get it to work globally?


  • I want to install a command line journal application with pip called jrnl. It works fine if you do "sudo pip install jrnl", however, I'm guessing this is a cringe-worthy way to do it.

  • If I install without sudo just using "pip install jrnl" it installs in .local/ without global access.

I've found several ways to do it but wondering if there is a common and accepted way to do it that is secure?


  • Add that location to your path! – George Udosen Jun 24 '18 at 11:56

It can be installed anywhere that is in your path. Several options I found are:

  1. Install to .local via:

    • pip install --user <pip-pkg-name>
    • This will install it in .local as you have noted so that location needs to be in your path, using the .bashrc file that can be done.
    • Add this export PATH=$PATH:/home/$USER/.local/bin to your /home/$USER/.bashrc file. With that you can reach it from anywhere.
  2. Add a custom path for with this line export PYTHONUSERBASE=/myappenv in your .bashrc file. Now when you do pip install --user <pip-pkg-name> it will be installed in /myappenv.

    • Note you have to create that path /myappenv first and add it to your .bashrc file with the line export PATH=$PATH:/myappenv
  3. Now that being said the so-called standard way you mentioned should be using python environment a.ka. virtualenv to install and run packages for that app and not globally as done in (1) and (2) above.

    • Install either for python2+ with sudo pip install virtualenv, or for python 3+ with sudo pip3 install virtualenv.
    • Usage:

      • virtualenv venv
      • Pick an interpreter of your choice with:

        • Python 2+: virtualenv -p python2.7 venv
        • Python 3+: virtualenv -p python3 myenv
      • Activate it: source venv/bin/activate
      • Deactivate it: deactivate




| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.