Skip to content

Instantly share code, notes, and snippets.

@bcchenbc
Created February 10, 2015 03:09
Show Gist options
  • Save bcchenbc/5bc6a46f679346e5cddd to your computer and use it in GitHub Desktop.
Save bcchenbc/5bc6a46f679346e5cddd to your computer and use it in GitHub Desktop.
simple process to have a working pip without root privilege
#!/bin/bash
##
# Adopted and edited from the solution by Evgeny at askbot.org
# http://askbot.org/en/question/2492/how-to-install-python-easy_install-python-distutils-in-root-or-non-root-account/
# and instruction provided by authors of setuptools.
# https://pypi.python.org/pypi/setuptools
#
# Please be noticed that the virtual environment directory was set to ~/.pyvenv
# you might want to change it.
# I use only python3, no suffix was added to the directory.
# If you need to use both 2 & 3, it would be better to create 2 virtual environment directories.
##
# initiate a virtual environment
pyvenv-3.3 ~/.pyvenv
# add settings to .bashrc
PYTHONPATH=~.pyvenv/lib/python3.3/site-packages
export PYTHONPATH
# get and install setuptools, for a copy of easy_install
wget https://bootstrap.pypa.io/ez_setup.py -O - | python3 - --user
# get and install pip
wget https://bootstrap.pypa.io/get-pip.py -O - | python3 - --user
# give direction to the pip:
# you might want to add these lines to .bashrc
PATH=~/.local/bin/:$PATH
export PATH
# or, to add an alias, just save some keystroke for 'install'
alias pipu='~/.local/bin/pip3 install --user'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment