标签:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | python -V? # 查看版本:Python 2.6.6? mkdir -p ~/Env/python; cd ~/Env/python? # 创建个目录? wget --no-check-certificate https://www.python.org/ftp/python/2.7.6/Python-2.7.6.tar.xztar Jxvf Python-2.7.6.tar.xzcd Python-2.7.6./configure --prefix=/usr/local/py-2.7.6? # "./configure -h"查看帮助make? # 报模块缺失时,有需要的安装后重make# issue: INFO: Can‘t locate Tcl/Tk libs and/or headers#??????? Python build finished, but the necessary bits to build these modules were not found:#??????? ...# 注1:zlib必要,之后安装setuptools要用。见"安装setuptools"。# 注2:openssl必要,之后pip要用。见"安装pip"。# 注3:bzip2也最好加,执行"yum install bzip2 bzip2-devel -y"。make install? # 建立软链接,默认指向Python2.7mv /usr/bin/python /usr/bin/python2.6.6ln -s /usr/local/py-2.7.6/bin/python2.7 /usr/bin/pythonpython -V? # Python 2.7.6? # yum不兼容Python2.7,需要指定为原版本vi /usr/bin/yum# 将"!/usr/bin/python"改为"!/usr/bin/python2.6.6"? # ibus也不兼容Python2.7,需要修改# 将"exec python"改为"exec python2.6.6"ll /usr/bin | grep python? # 确认下python2.6.6vi /usr/bin/ibus-setup? # 修改vi /usr/libexec/ibus-ui-gtk? # 修改reboot? # 可能需要重启 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | cd ~/Env/python? wget http://pypi.douban.com/packages/source/s/setuptools/setuptools-3.3.tar.gz? # 豆瓣源tar zxvf setuptools-3.3.tar.gzcd setuptools-3.3python setup.py buildsudo python setup.py install# 或者用ez_setup.py,同样改为豆瓣源# wget https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py# python ez_setup.py --download-base http://pypi.douban.com/packages/source/s/setuptools/? # 缺少zlib,安装setuptools时出错。# issue: RuntimeError: Compression requires the (missing) zlib moduleyum install zlib zlib-devel -y# 重make Python2.7再安装cd ../Python-2.7.6make? # 这时才注意先前make时缺了好多模块make install? # 环境变量vi /etc/profile# 添加如下内容:# PY_HOME=/usr/local/py-2.7.6# export PATH=$PY_HOME/bin:$PATHsource /etc/profile? # 当前终端生效,reboot后才会完全生效echo $PATH |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | easy_install -i http://pypi.douban.com/simple pip? # 缺少ssl模块,pip使用时出错# issue: ImportError: cannot import name HTTPSHandleryum install openssl openssl-devel -ymake? # Python-2.7.6目录make install? # 配置pip为豆瓣源mkdir ~/.pip? # ls或ll -a 查看隐藏内容vi ~/.pip/pip.conf# 添加如下内容:# [global]# index-url = http://pypi.douban.com/simple |
1 2 3 | supip install virtualenvpip install virtualenvwrapper |
virtualenv用于创建隔离的Python运行环境,依赖不同库和版本时避免混乱。
virtualenvwrapper为virtualenv上的扩展,提供更方便的命令。
标签:
原文地址:http://www.cnblogs.com/highroom/p/a41f335dc3880bba1e10a0d954241a1c.html