简体   繁体   中英

How can pip be installed locally for use with Python 2.7?

I want to install pip locally together with a local install of Python 2.7. I am using an EPEL6 system on which I am not root. I have easy_install available on the system by default (no pip or virtualenv to begin with).

I have managed to install pip and Python 2.7, but I don't know how to proceed to get pip working with the Python 2.7 install (as opposed to Python 2.6).

cd
mkdir local_test
cd local_test

wget https://www.python.org/ftp/python/2.6/Python-2.6.tgz
tar -xvf Python-2.6.tgz
cd Python-2.6
./configure --prefix=/home/user/local_test
make
make install
cd ..
rm -rf Python-2.6
rm Python-2.6.tgz

wget https://www.python.org/ftp/python/2.7.12/Python-2.7.12.tgz
tar -xvf Python-2.7.12.tgz
cd Python-2.7.12
./configure --prefix=/home/user/local_test
make
make install
cd ..
rm -rf Python-2.7.12
rm Python-2.7.12.tgz

export PYTHONPATH=/home/user/local_test/lib/python2.6/site-packages:${PYTHONPATH}

easy_install --prefix=~/local_test pip

export PATH=/home/user/local_test/bin:$PATH

I suggest using Miniconda to manage your entire Python environment. This way, you can avoid doing any configure / make steps, and it will come with pip by default. It replaces the need for virtualenv , and can be easily installed in your home directory.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM