发布时间:2019-06-30 16:53:12编辑:auto阅读(1826)
[root@qsh ~]# cat /etc/centos-release CentOS Linux release 7.6.1810 (Core)
[root@qsh ~]# python -V Python 2.7.5 [root@qsh usr]# ll -l /usr/bin/python* lrwxrwxrwx 1 root root 7 3月 29 22:44 /usr/bin/python -> python2 lrwxrwxrwx 1 root root 9 3月 29 22:44 /usr/bin/python2 -> python2.7 -rwxr-xr-x 1 root root 7136 11月 6 00:29 /usr/bin/python2.7
[root@qsh packages]# wget https://www.python.org/ftp/python/2.7.15/Python-2.7.15.tgz [root@qsh packages]# tar zxvf Python-2.7.15.tgz
yum install gcc* openssl openssl-devel ncurses-devel.x86_64 bzip2-devel sqlite-devel python-devel zlib
cd Python-2.7.15 ./configure --prefix=/usr/local # [配置]指定可执行文件、库文件、配置文件、资源文件的安装路径。若没有权限加sudo make # 编译 make altinstall # 不要使用make install,否则会覆盖系统自带python
[root@qsh ~]# python -V # 发现版本还是原版本Python 2.7.5
[root@qsh ~]# ll -l /usr/bin/python* # 系统自带的 lrwxrwxrwx 1 root root 7 2019/03/03 14:24:13 /usr/bin/python -> python2 lrwxrwxrwx 1 root root 9 2019/03/03 14:24:13 /usr/bin/python2 -> python2.7 -rwxr-xr-x 1 root root 7216 2018/10/31 07:46:45 /usr/bin/python2.7 -rwxr-xr-x 1 root root 1835 2018/10/31 07:46:26 /usr/bin/python2.7-config lrwxrwxrwx 1 root root 16 2019/03/26 17:13:24 /usr/bin/python2-config -> python2.7-config lrwxrwxrwx 1 root root 14 2019/03/26 17:13:24 /usr/bin/python-config -> python2-config [root@qsh ~]# ll -l /usr/local/bin/python* # 手工安装的 -rwxr-xr-x 1 root root 8296384 2019/03/26 17:16:56 /usr/local/bin/python2.7 -rwxr-xr-x 1 root root 1687 2019/03/26 17:17:05 /usr/local/bin/python2.7-config
[root@qsh ~]# mv /usr/bin/python /usr/bin/python2.7.5 [root@qsh ~]# ll -l /usr/bin/python* lrwxrwxrwx 1 root root 9 2019/03/03 14:24:13 /usr/bin/python2 -> python2.7 -rwxr-xr-x 1 root root 7216 2018/10/31 07:46:45 /usr/bin/python2.7 lrwxrwxrwx 1 root root 7 2019/03/03 14:24:13 /usr/bin/python2.7.5 -> python2 # 改为2.7.5 -rwxr-xr-x 1 root root 1835 2018/10/31 07:46:26 /usr/bin/python2.7-config lrwxrwxrwx 1 root root 16 2019/03/26 17:13:24 /usr/bin/python2-config -> python2.7-config lrwxrwxrwx 1 root root 14 2019/03/26 17:13:24 /usr/bin/python-config -> python2-config [root@qsh ~]# ln -s /usr/local/bin/python2.7 /usr/bin/python # 增加连接 [root@qsh ~]# ll -l /usr/bin/python* lrwxrwxrwx 1 root root 24 2019/03/26 17:20:18 /usr/bin/python -> /usr/local/bin/python2.7 # 新增的,并指向新安装的python lrwxrwxrwx 1 root root 9 2019/03/03 14:24:13 /usr/bin/python2 -> python2.7 -rwxr-xr-x 1 root root 7216 2018/10/31 07:46:45 /usr/bin/python2.7 lrwxrwxrwx 1 root root 7 2019/03/03 14:24:13 /usr/bin/python2.7.5 -> python2 -rwxr-xr-x 1 root root 1835 2018/10/31 07:46:26 /usr/bin/python2.7-config lrwxrwxrwx 1 root root 16 2019/03/26 17:13:24 /usr/bin/python2-config -> python2.7-config lrwxrwxrwx 1 root root 14 2019/03/26 17:13:24 /usr/bin/python-config -> python2-config
[root@qsh ~]# python -V Python 2.7.15
[root@qsh ~]# python2.7.5 -V Python 2.7.5
[root@qsh ~]# yum -y install epel-release There was a problem importing one of the Python modules required to run yum. The error leading to this problem was: No module named yum #这时候报错了 Please install a package which provides this module, or verify that the module is installed correctly. It's possible that the above module doesn't match the current version of Python, which is: 2.7.13 (default, Apr 2 2017, 04:48:29) [GCC 4.8.5 20150623 (Red Hat 4.8.5-11)] If you cannot solve this problem yourself, please go to the yum faq at: http://yum.baseurl.org/wiki/Faq #解决方法 [root@qsh ~]# vi /usr/bin/yum 首行的#!/usr/bin/python 改为 #!/usr/bin/python2.7 改完之后继续安装,又报错... ImportError: No module named urlgrabber.grabber [root@qsh ~]# vi /usr/libexec/urlgrabber-ext-down 首行的#!/usr/bin/python 改为 #!/usr/bin/python2.7
1. 下载安装
wget https://bootstrap.pypa.io/get-pip.py python get-pip.py
2. 设置软连接
ln -s /usr/local/python27/bin/pip2.7 /usr/bin/pip
#安装 ipython
pip install ipython==1.2.1 ln -s /usr/local/python27/bin/ipython /usr/bin/ipython
上一篇: python学习笔记13-python面
下一篇: Windows Server 2003
48876
47942
38721
35864
30289
27046
26075
20911
20714
19076
512°
612°
616°
618°
595°
579°
645°
718°
836°
943°