Skip to content

Instantly share code, notes, and snippets.

@deoren
Forked from saurabhshri/pip.md
Last active January 23, 2018 03:54
Show Gist options
  • Save deoren/1c1e73818e26fb1e69fb26a0bf4bdbf4 to your computer and use it in GitHub Desktop.
Save deoren/1c1e73818e26fb1e69fb26a0bf4bdbf4 to your computer and use it in GitHub Desktop.
Install and use pip in a local directory without root/sudo access.

Install and use pip in a local directory without root/sudo access.

By: @saurabhshri

Why?

Many users when are given server access, do not have root (or sudo) privileges and can not simply do sudo apt-get install python-pip . Here's an easy way you can install and use pip without root (or sudo) access in a local directory. Note : This works without easy_install too.

How?

  1. Download pip from an online repository : wget https://bootstrap.pypa.io/get-pip.py
  2. Install the downloaded package into a local directory : python get-pip.py --user This will install pip to your local directory (.local/bin).
  3. Now you may navigate to this directory (cd .local/bin) and then use pip or better set your $PATH variable this directory to use pip anywhere : PATH=$PATH:~/.local/bin followed by source ~/.bashrc to apply the changes.

And that's it. You may now install all python modules you require via pip in a local directory without root.

Gist of Gist

wget https://bootstrap.pypa.io/get-pip.py && python get-pip.py --user
cd .local/bin
./pip install <package_name> --user
@deoren
Copy link
Author

deoren commented Jan 23, 2018

As of the time this Gist entry was created, GitHub does not support notifications for comments for mentions to Gist entries (see isaacs/github#21 for details). Please contact me via Twitter or file an issue in the deoren/leave-feedback repo (created for that very purpose) if you wish to receive a response for your feedback. Thank you in advance!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment