1、配置共享库 /etc/ld.so.conf
include ld.so.conf.d/*.conf
/usr/local/lib
2、下载源码编译
# Python 2.7.6:
wget http://python.org/ftp/python/2.7.6/Python-2.7.6.tar.xz
tar xf Python-2.7.6.tar.xz
cd Python-2.7.6
./configure --prefix=/usr/local --enable-unicode=ucs4 --enable-shared LDFLAGS="-Wl,-rpath /usr/local/lib"
make && make altinstall
# Python 3.3.5:
wget http://python.org/ftp/python/3.3.5/Python-3.3.5.tar.xz
tar xf Python-3.3.5.tar.xz
cd Python-3.3.5
./configure --prefix=/usr/local --enable-shared LDFLAGS="-Wl,-rpath /usr/local/lib"
make && make altinstall
安装好后,查看/usr/local/bin/python2.7
or /usr/local/bin/python3.3 是否安装成功
3、安装pip
# First get the setup script for Setuptools:
wget https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py
# Then install it for Python 2.7 and/or Python 3.3:
python2.7 ez_setup.py
python3.3 ez_setup.py
# Now install pip using the newly installed setuptools:
easy_install-2.7 pip
easy_install-3.3 pip
# With pip installed you can now do things like this:
pip2.7 install [packagename]
pip2.7 install --upgrade [packagename]
pip2.7 uninstall [packagename]
4、配置虚拟环境,创建相应的工程
# Install virtualenv for Python 2.7 and create a sandbox called my27project:
pip2.7 install virtualenv
virtualenv-2.7 my27project
# Use the built-in pyvenv program in Python 3.3 to create a sandbox called my33project:
pyvenv-3.3 my33project
# Check the system Python interpreter version:
python --version
# This will show Python 2.6.6
# Activate the my27project sandbox and check the version of the default Python interpreter in it:
source my27project/bin/activate
python --version
# This will show Python 2.7.6
deactivate
# Activate the my33project sandbox and check the version of the default Python interpreter in it:
source my33project/bin/activate
python --version
# This will show Python 3.3.5
deactivate