记录一次CentOS环境升级Python2.6到Python2.7并安装最新版pip
背景介绍
一次实验中需要安装python-etcd包。安装这个包时要求的python和pip版本比目前系统的版本高。
系统是centos6.6 64位
|
1
2
3
4
5
6
7
|
[root@minion01 ~]# uname -r2.6.32-504.el6.x86_64[root@minion01 ~]# uname -mx86_64[root@minion01 ~]# cat /etc/redhat-releaseCentOS release 6.6 (Final)[root@minion01 ~]# |
使用pip安装python-ectd包时提示命令找不到,需要先安装python-pip,pip是python的包管理工具
|
1
2
3
4
5
6
|
[root@minion01 ~]# pip install python-etcd-bash: pip: command not found[root@minion01 ~]# yum install python-pip -yInstalled: python-pip.noarch 0:7.1.0-1.el6 此处省略安装过程 [root@minion01 ~]# |
继续安装python-ectd,提示pip版本太低,需要先升级pip。
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
[root@minion01 ~]# pip install python-etcd/usr/lib/python2.6/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:90: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning. InsecurePlatformWarningYou are using pip version 7.1.0, however version 9.0.1 is available.You should consider upgrading via the 'pip install --upgrade pip' command.Collecting python-etcd/usr/lib/python2.6/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:90: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning. InsecurePlatformWarning Downloading python-etcd-0.4.3.tar.gz Complete output from command python setup.py egg_info: Traceback (most recent call last): File "<string>", line 20, in <module> File "/tmp/pip-build-dByULi/python-etcd/setup.py", line 12, in <module> if sys.version_info.major == 2: AttributeError: 'tuple' object has no attribute 'major' ----------------------------------------Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-dByULi/python-etcd |
按照上面的提示先升级pip
|
1
2
3
4
5
6
7
8
9
10
11
12
13
|
[root@minion01 ~]# pip install --upgrade pipYou are using pip version 7.1.0, however version 9.0.1 is available.You should consider upgrading via the 'pip install --upgrade pip' command./usr/lib/python2.6/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:90: InsecurePlatformWarning: A true SSLContext object is not available. <br>This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning. InsecurePlatformWarningCollecting pip Downloading pip-9.0.1-py2.py3-none-any.whl (1.3MB) 100% |████████████████████████████████| 1.3MB 46kB/sInstalling collected packages: pip Found existing installation: pip 7.1.0 Uninstalling pip-7.1.0: Successfully uninstalled pip-7.1.0Successfully installed pip-9.0.1 |
继续执行命令,提示python版本太低
|
1
2
3
4
5
6
7
8
9
10
11
12
13
|
[root@minion01 ~]# pip install python-etcdDEPRECATION: Python 2.6 is no longer supported by the Python core team, please upgrade your Python. A future version of pip will drop support for Python 2.6Collecting python-etcd Using cached python-etcd-0.4.3.tar.gz Complete output from command python setup.py egg_info: Traceback (most recent call last): File "<string>", line 1, in <module> File "/tmp/pip-build-okuCUU/python-etcd/setup.py", line 12, in <module> if sys.version_info.major == 2: AttributeError: 'tuple' object has no attribute 'major' ----------------------------------------Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-okuCUU/python-etcd/ |
查看当前系统默认的python版本
|
1
2
|
[root@minion01 ~]# python -VPython 2.6.6 |
下载并解压python2.7.10
新建一个tools目录用于存放下载的tar包,下载并解压,命令如下
|
1
2
3
4
5
6
|
[root@minion01 ~]# mkdir /tools -p[root@minion01 ~]# cd /tools[root@minion01 tools]# wget http://www.python.org/ftp/python/2.7.10/Python-2.7.10.tar.xz[root@minion01 tools]# unxz Python-2.7.10.tar.xz[root@minion01 tools]# tar -xf Python-2.7.10.tar[root@minion01 tools]# cd Python-2.7.10 |
配置编译参数
|
1
|
[root@minion01 Python-2.7.10]# ./configure --enable-shared --enable-loadable-sqlite-extensions --with-zlib |
修改一个文件
|
1
2
|
[root@minion01 Python-2.7.10]# vim ./Modules/Setup找到#zlib zlibmodule.c -I$(prefix)/include -L$(exec_prefix)/lib -lz去掉注释并保存,然后进行编译和安装 |
编译和安装
|
1
|
[root@minion01 Python-2.7.10]# make && make install |
查看安装后的结果,备份原先的可执行文件,给新的文件做软链接
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
[root@minion01 Python-2.7.10]# ll /usr/local/bin/total 48-rwxr-xr-x 1 root root 101 Dec 19 13:29 2to3-rwxr-xr-x 1 root root 99 Dec 19 13:29 idle-rwxr-xr-x 1 root root 84 Dec 19 13:29 pydoclrwxrwxrwx 1 root root 7 Dec 19 13:29 python -> python2lrwxrwxrwx 1 root root 9 Dec 19 13:29 python2 -> python2.7-rwxr-xr-x 1 root root 9776 Dec 19 13:29 python2.7-rwxr-xr-x 1 root root 1687 Dec 19 13:29 python2.7-configlrwxrwxrwx 1 root root 16 Dec 19 13:29 python2-config -> python2.7-configlrwxrwxrwx 1 root root 14 Dec 19 13:29 python-config -> python2-config-rwxr-xr-x 1 root root 18547 Dec 19 13:29 smtpd.py[root@minion01 Python-2.7.10]# mv /usr/bin/python /usr/bin/python_bak[root@minion01 Python-2.7.10]# ln -s /usr/local/bin/python2.7 /usr/bin/python |
再次查看版本,遇到如下报错,修改配置文件
|
1
2
3
4
5
6
7
8
9
10
|
[root@minion01 Python-2.7.10]# python -Vpython: error while loading shared libraries: libpython2.7.so.1.0: cannot open shared object file: No such file or directory<br>编辑配置文件,添加新的一行内容/usr/local/lib,保存退出[root@minion01 Python-2.7.10]# vim /etc/ld.so.conf<br><br>查看添加后的结果,在第一行[root@minion01 Python-2.7.10]# cat /etc/ld.so.conf/usr/local/libinclude ld.so.conf.d/*.conf<br><br>执行ldconfig加载配置[root@minion01 Python-2.7.10]# ldconfig<br><br>再次执行查看版本命令,正确显示[root@minion01 Python-2.7.10]# python -VPython 2.7.10 |
再次执行安装python-ectd,有报错。pip有问题
|
1
2
3
4
5
6
|
[root@minion01 tools]# pip install python-etcdTraceback (most recent call last): File "/usr/bin/pip", line 7, in <module> from pip import mainImportError: No module named pip[root@minion01 tools]# |
为了解决上面问题,手动安装pip,依次执行下面命令
|
1
2
3
4
5
|
[root@minion01 Python-2.7.10]# cd ..[root@minion01 tools]# wget https://bootstrap.pypa.io/get-pip.py[root@minion01 tools]# python get-pip.py[root@minion01 tools]# mv /usr/bin/pip /usr/bin/pip_bak[root@minion01 tools]# ln -s /usr/local/bin/pip2.7 /usr/bin/pip |
再次安装python-ectd,成功执行
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
再次安装python-etcd,成功了[root@minion01 tools]# pip install python-etcdCollecting python-etcd Using cached python-etcd-0.4.3.tar.gzCollecting urllib3>=1.7.1 (from python-etcd) Downloading urllib3-1.19.1-py2.py3-none-any.whl (104kB) 100% |████████████████████████████████| 112kB 65kB/sCollecting dnspython (from python-etcd) Downloading dnspython-1.15.0-py2.py3-none-any.whl (177kB) 100% |████████████████████████████████| 184kB 68kB/sBuilding wheels for collected packages: python-etcd Running setup.py bdist_wheel for python-etcd ... done Stored in directory: /root/.cache/pip/wheels/a4/72/72/513173535d5ec25c11dbb53ce7c53c92746bff62b362a402a7Successfully built python-etcdInstalling collected packages: urllib3, dnspython, python-etcdSuccessfully installed dnspython-1.15.0 python-etcd-0.4.3 urllib3-1.19.1[root@minion01 tools]# |
记录一次CentOS环境升级Python2.6到Python2.7并安装最新版pip的更多相关文章
- python2和python3同时存在如何安装和使用pip
linux下 如果没有pip则需要安装pip python2安装pip sudo apt install python-pip1如果是python3,则如下: sudo apt install pyt ...
- CentOS环境 升级Python2.6.6至2.7.5
1.查看当前Python版本 # python -V Python 2.6.6 # python -V Python 2.6.6 2.下载Python2.7.5源码 # wget http://p ...
- CentOS 5升级Python版本(2.4>2.7)
安装SALT时,需要这样作,公司有一批REDHAT5的,弄起来... 然后却是: Missing Dependency: python(abi) = 2.6 is needed by package ...
- 在阿里云的CentOS环境中安装django
购买了一台阿里云主机.操作系统为CentOS 6.5.准备在上面跑Django做Web开发.因为CentOS自带的python版本号较低,安装Django先要安装新版本号python.还是费了点周折. ...
- centos环境的python、scrapy部署
1 操作系统 Centos 6.5 64bit 或以上版本 2 软件环境 提示:(1)用什么软件:(2)运行环境(3)开发包. Python:Python-2.7.6.tgz Scrapy:Scrap ...
- CENTOS 7 升级安装 Python 3.5
写在前面的话 本文采取源码的方式安装 Python 3.5.2,如果是其它版本会有或多或少的差异,且写这篇的时候官网最新的是 Python 3.7,个人使用 3.5 就足够了,没必要更新到最新,否则出 ...
- CentOS环境安装python3,pip
安装python3(编译安装) 1. 下载python安装包到指定目录 cd /usr/local/src 这里的目录如果不存在可以自己建,当然也可以自己放在自己想放的位置,只要等会儿安装的时候能找到 ...
- Apache Superset1.2.0教程(四)—— CentOS环境安装
前文中,我们已经在windows环境进行了superset的安装,也对图表功能进行了展示.但是在平时使用以及生产环境中,还是需要在centos环境下进行操作. 本文将带大家详解在centos7环境进行 ...
- centos 7 升级后yum install出现Exiting on user cancel
centos 7 升级后yum install出现Exiting on user cancel centos 7.x升级后用yum install进行安装时经常出现Exiting on user ca ...
随机推荐
- phpstorm ctrl+shift+F键不管用,不弹出搜索弹框
般热键冲突搜狗默认简繁切换组合键位ctrl+shift+F故outlook2011按三建且失效应该能看搜狗输入状态简繁变搜狗设置按键-取消选简繁切换热键即在任务栏的语言地方点击一下再点击语言首选项.进 ...
- WOW.js – 让页面滚动更有趣
演示1 演示2-仿oppo首页 下载 简介 有的页面在向下滚动的时候,有些元素会产生细小的动画效果.虽然动画比较小,但却能吸引你的注意.比如刚刚发布的 iPhone 6 的页面(查看).如果你希望你的 ...
- 注释中不允许出现字符串 "--"。
问题: 在启动tomcat时会出现如上错误,同时有可能会出现xml无法解析等错误 解决办法: 注释中不能出现字符串 "--",即需要把xml文件中多余的“--”去掉,例如: < ...
- JXLS使用方法(文件上传读取)xlsx文件读取
1.官方文档:http://jxls.sourceforge.net/reference/reader.html 2.demo git地址:https://bitbucket.org/leonate/ ...
- requests关于Exceeded 30 redirects问题得出的结论
昨天一个朋友在爬网页时出现的一个问题,以及后续我对这个问题进行了简单的测试. 先说出现的问题的简单描述. 首先是使用urllib请求网页: #urllib.request发起的请求 import ur ...
- SQL 优化经验总结34条(转)
(1) 选择最有效率的表名顺序(只在基于规则的优化器中有效): ORACLE 的解析器按照从右到左的顺序处理FROM子句中的表名,FROM子句中写在最后的表(基础表 driving table)将被最 ...
- java里程碑之泛型--擦除和转换
在严格的泛型代码里,带泛型声明的类总应该带着泛型参数.但是为了和古老的java代码保持一致,也就是说为了向下兼容,也允许在使用带泛型声明的类时不指定实际的类型参数.如果没有为这个泛型类指定实际的参数类 ...
- 从LINQ开始之LINQ to Objects(上)
LINQ概述 LINQ,语言集成查询(Language Integrated Query),它允许使用C#或VB代码以查询数据库相同的方式来操作不同的数据源. LINQ体系结构 从上图可以看出,LIN ...
- ORACLE约束总结
你对ORACLE约束的了解如何?比较模糊还是相当透彻?如果你对下面几个问题了如指掌的话,恭喜你,你已经对约束掌握得比较好了,不用看这篇文章了.ORACLE的约束有啥功能作用? 有哪些类型约束(不同版本 ...
- Android Acitivy切换平移动画效果实现
1.在anim目录下新建anim文件夹,新建tran_in.xml和tran_out.xml分别表示下一页切换进入,和本页切换出去. 即in表示下一页向左平移,out表示同样向左平移至消失. tran ...