一.环境
ubuntu14.04
二.准备
2.1更新软件库
sudo apt-get update
2.2安装编译器及相应工具
2.3安装相应的开发库
sudo apt-get install zlib1g-dev libbz2-dev libssl-dev libncurses5-dev libsqlite3-dev libreadline-dev tk-dev libgdbm-dev libdb-dev libpcap-dev xz-utils libexpat-dev
2.4安装python
2.4.1获取python2.7.13
wget http://python.org/ftp/python/2.7.13/Python-2.7.13.tar.xz
2.4.2解压
tar xvf Python-2.7.13.tar.xz
2.4.3进入目录Python-2.7.13
cd Python-2.7.13
2.4.4配置
./configure --prefix=/usr/local --enable-unicode=ucs4 --enable-shared LDFLAGS="-Wl,-rpath /usr/local/lib"
2.4.5安装
make -j10 && sudo make install
2.5 安装pip
2.5.1获取脚本
wget https://bootstrap.pypa.io/get-pip.py
2.5.2执行脚本(安装pip setuptool wheel)
sudo python2.7 get-pip.py
2.5.3安装你想安装的软件
sudo pip2.7 install 软件包名
2.6创建隔离的python环境
2.6.1安装virtualenv
sudo pip2.7 install virtualenv
2.6.2创建环境
virtualenv myOwnPython2_7Env
2.6.3激活
source myOwnPython2_7Env/bin/activate
2.6.4现在可以检查版本是不是2.7.13
python --version
2.6.5关闭
deactivate