CentOS Upgrade Python2.7 and install Pip

Source: Internet
Author: User
Tags install openssl install django pip install django virtualenv

<title>CentOS Upgrade Python2.7 and install Pip</title> CentOS Upgrade Python2.7 and install PIP1) upgrade Python2.7?
1234567891011121314151617181920212223242526272829303132 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? # 可能需要重启
2) Prepare the Base environment 2.1) Install Setuptools
?
1234567891011121314151617181920212223242526 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
2.2) Install Pip
?
1234567891011121314 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
2.3) Install Virtualenv
?
123 supip install virtualenvpip install virtualenvwrapper

Virtualenv is used to create an isolated Python runtime environment, which avoids confusion when it relies on different libraries and versions.

The Virtualenvwrapper provides more convenient commands for extensions on the virtualenv.

2.4) Other document
    • Sphinx
      • ' Pip install Sphinx '
Network
    • Twisted
      • ' Pip install Twisted '
      • Zope.interface
    • Scrapy
      • ' Pip install Scrapy '
Web Framework
    • Django
      • ' Pip install Django '
    • Tornado
      • ' Pip install Tornado '
    • Flask
      • ' Pip install Flask '



From for notes (Wiz)

CentOS Upgrade Python2.7 and install Pip

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.