时间:2021-05-19
1. 准备工作
下载源码包
wget http://python.org/ftp/python/2.7.3/Python-2.7.3.tar.bz2查看是否安装make工具
~#rpm -qa|grep makeautomake-1.11.1-4.el6.noarchmake-3.81-20.el6.x86_64如果没有安装make工具
yum -y install gcc automake autoconf libtool make查看是否安装zlib库
~#rpm -qa|grep zlibzlib-devel-1.2.3-29.el6.x86_64zlib-1.2.3-29.el6.x86_64安装zlib
yum install zlib-devel检查是否安装ssl 库
~#rpm -qa|grep opensslopenssl-devel-1.0.1e-16.el6_5.x86_64openssl-static-1.0.1e-16.el6_5.x86_64openssl098e-0.9.8e-17.el6.centos.2.x86_64openssl-1.0.1e-16.el6_5.x86_64openssl-perl-1.0.1e-16.el6_5.x86_64安装openssl
yum install openssl*安装bzip2依赖库
yum install -y bzip2*2. 编译安装
cp Python-2.7.3.tar.bz2 /usr/src/tar -jxvf Python-2.7.3.tar.bz2vi Modules/Setup.dist找到
#SSL=/usr/local/ssl#_ssl _ssl.c \# -DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \# -L$(SSL)/lib -lssl -lcrypto......#zlib zlibmodule.c -I$(prefix)/include -L$(exec_prefix)/lib -lz把注释去掉
编译
./configure --prefix=/usr/local/python2.7make all make installmake cleanmake distclean安装成功
~#/usr/local/python2.7/bin/python2.7Python 2.7.3 (default, Dec 18 2013, 15:43:35) [GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux2Type "help", "copyright", "credits" or "license" for more information.>>> cd /usr/local/python2.7python setup.py install建立python2.7 软链
~#mv /usr/bin/python /usr/bin/python.bak~#ln -s /usr/local/python2.7/bin/python2.7 /usr/bin/python2.7~#ln -s /usr/bin/python2.7 /usr/bin/python3. 解决yum无法使用的问题
~#yum updateThere was a problem importing one of the Python modulesrequired to run yum. The error leading to this problem was: No module named yumPlease install a package which provides this module, orverify that the module is installed correctly.It's possible that the above module doesn't match thecurrent version of Python, which is:2.7.3 (default, Dec 18 2013, 15:43:35) [GCC 4.4.7 20120313 (Red Hat 4.4.7-4)]If you cannot solve this problem yourself, please go to the yum faq at: http://yum.baseurl.org/wiki/Faq因为centos 6.4 下yum默认使用的是python2.6
vi /usr/bin/yum----------------------------------------------------#!/usr/bin/pythonimport systry: import yumexcept ImportError:.......修改为
#!/usr/bin/python2.6........4. 安装python-pip工具
先安装setup-tools
wget https://pypi.python.org/packages/2.7/s/setuptools/setuptools-0.6c11-py2.7.egg --no-check-certificatechmod +x setuptools-0.6c11-py2.7.eggsh setuptools-0.6c11-py2.7.egg安装pip
wget https://pypi.python.org/packages/source/p/pip/pip-1.3.1.tar.gz --no-check-certificatecp pip-1.3.1.tar.gz /usr/src/tar zxvf pip-1.3.1.tar.gzcd pip-1.3.1python setup.py installln -s /usr/local/python2.7/bin/pip /usr/bin/pip声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。
centos6自带python2.6版本,根据需要,安装python2.7、easy_install-2.7、pip2.7依赖yumgroupinstall-y
参考服务器安装的是Centos系统。uwsgi是使用pip安装的。nginx是使用yuminstallnginx安装。python2.7,mysql5.5使用y
安装软件安装Python2.7、PyCharm、pip(Python包管理工具)、Django(pipinstallDjango)部署PyCharm新建Djan
centos7之Python3.74安装安装版本:Python3.74系统版本:centos7系统默认安装Python2.7,保留。安装/usr/bin/Pyt
Question: centos7中Python-pip模块不存在,是因为像centos这类衍生的发行版,源跟新滞后,或者不存在。即使使用yum去search