Upgrade Python And Pip On CentOS 6.x
2015-12-22 14:10
701 查看
下载python2.7源码,编译安装
安装openssl
与openssl-devel
包
# yum install openssl # yum install openssl-devel
进入python源代码文件夹,修改Modules/Setup.dist
文件
#vim Setup.dist 修改 # Socket module helper for SSL support; you must comment out the other # socket line above, and possibly edit the SSL variable: #SSL=/usr/local/ssl #_ssl _ssl.c \ # -DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \ # -L$(SSL)/lib -lssl -lcrypto 为 # Socket module helper for SSL support; you must comment out the other # socket line above, and possibly edit the SSL variable: SSL=/usr/local/ssl _ssl _ssl.c \ -DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \ -L$(SSL)/lib -lssl -lcrypto
安装python
# ./configure --prefix=/usr/local/python2.7 # make all # make install
替换原有python2.6版本
# rm -rf /usr/bin/python # ln -s /usr/local/python2.7/bin/python /usr/bin/ # vim /usr/bin/yum To: #!/usr/bin/python2.6 ...
重新安装pip
安装setuptools:
# curl https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py | python
安装pip
easy_install pip
此时
pip安装在新版python目录的bin目录: /usr/local/python2.7/bin/下
需要软链到/usr/bin/pip下方能正常使用
# ln -s /usr/local/python2.7/bin/pip2.7 /usr/bin/pip
测试
# pip install pymongo Collecting pymongo Downloading http://pypi.douban.com/packages/source/p/pymongo/pymongo-3.2.tar.gz (473kB) 100% |████████████████████████████████| 475kB 1.0MB/s Installing collected packages: pymongo Running setup.py install for pymongo Successfully installed pymongo-3.2 # python Python 2.7.11 (default, Dec 22 2015, 13:41:47) [GCC 4.4.7 20120313 (Red Hat 4.4.7-16)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import pymongo >>>
End!
相关问题:
1, 升级python2.6到2.7以后执行pip会报这个错误:
Traceback (most recent call last): File "/var/www/mydir/virtualenvs/dev/bin/pip", line 5, in <module> from pkg_resources import load_entry_point ImportError: No module named pkg_resources
重新安装一下setuptools即可解决:
curl https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py | python
2, python自带url库默认不支持https
导致在执行安装setuptools是出错:
urllib2.URLError: <urlopen error unknown url type: https>
解决办法参考文章上面修改:
Modules/Setup.dist部分
相关链接:
https://pypi.python.org/pypi/distribute/0.6.10
相关文章推荐
- LDD: ch4补充,seq_file的介绍
- linux下安装node.js
- linux ibus提示没有输入框
- Linux新建用户 useradd&groupadd
- centOS 6.5下升级mysql,从5.1升级到5.7
- linux环境搭建
- linux的grub相关操作
- Linux C 深入分析结构体指针的定义与引用
- linux ext2,ext3,ext4文件系统的区别(二)
- 驱动框架
- 10条命令,一分钟分析Linux性能问题
- JMeter:Linux上安装&运行JMeter
- VM VirtualBox安装Centos6.5
- Linux经常使用命令
- 每天一个Linux命令(1) ls
- Linux常用操作命令
- CentOS 6 用SVN自动提交文件到web服务器
- 详解Linux系统中安装配置Samba服务器的步骤
- CentOS代理设置
- Linux命令行技巧