By: @saurabhshri
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.
- Download pip from an online repository :
wget https://bootstrap.pypa.io/get-pip.py
- Install the downloaded package into a local directory :
python get-pip.py --user
This will install pip to your local directory(.local/bin)
. - Now you may navigate to this directory
(cd .local/bin)
and then usepip
or better set your $PATH variable this directory to usepip
anywhere :PATH=$PATH:~/.local/bin
followed bysource ~/.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.
wget https://bootstrap.pypa.io/get-pip.py && python get-pip.py --user
cd .local/bin
./pip install <package_name> --user
I have zero recollection of when I wrote this gist, I just found it back while searching how to do it myself. Sadly Github doesn't notify about gist comments, so I missed the activity here.
@kenichi-shibata Thank you for fixing, I have updated formatting in the gist.
@greggman I have been using virtual environments to manage that too, as suggested by others.