升级为python3.3.7版本步骤

发布时间:2019-08-27 08:02:31编辑:auto阅读(1772)

    python环境搭建-Linux系统下python2.7升级python3.3.7步骤
    首先Python 查看版本 , 在Linux下特别注意权限问题,创建目录时候切记给予权限

    升级步骤
    升级为python3.3.7版本步骤

    #解压到下载目录,在编译前先在/usr/local建一个文件夹python3(以免覆盖老的版本)
    [root@svr7 ~]# tar -xf Python-3.3.7rc1.tar.xz
    [root@svr7 ~]# cd Python-3.3.7rc1/
    #进入解压后的文件夹,
    [root@svr7 Python-3.3.7rc1]#mkdir /usr/local/python3
    [root@svr7 Python-3.3.7rc1]#./configure --prefix=/usr/local/python3
    [root@svr7 Python-3.3.7rc1]#make && make install
    编译完成
    #此时没有覆盖老版本,再将原来/usr/bin/python链接改为别的名字
    [root@svr7 Python-3.3.7rc1]# mv /usr/bin/python /usr/bin/python_old
    [root@svr7 Python-3.3.7rc1]# python
    -bash: /usr/bin/python: 没有那个文件或目录
    [root@svr7 Python-3.3.7rc1]#  ln -s /usr/local/python3/bin/python3 /usr/bin/python
    [root@svr7 Python-3.3.7rc1]# python
    Python 3.3.7rc1 (default, Sep  7 2017, 21:25:49)
    [GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>>
    [root@svr7 Python-3.3.7rc1]# python --version
    Python 3.3.7rc1

    PS:如果不建立新安装路径python3,而是直接默认安装,则安装后的新python应该会覆盖linux下自带的老版本,也有可能不覆盖,具体看安装过程了,这个大家可以自己试验下,当然如果还想保留原来的版本,那么这种方法最好不过了。

    注意事项:
    这种方法虽然能安装成功,但会导致yum不能正常使用。
    解决方法:
    [root@svr7 Python-3.3.7rc1]#  cp /usr/bin/yum /usr/bin/yum.backup
    [root@svr7 Python-3.3.7rc1]# vim /usr/bin/yum
    修改第一行参数
    vi /usr/bin/yum   
    把  #!/usr/bin/python    修改为:/usr/bin/python_old  

    把  #!/usr/bin/python    修改为:/usr/bin/python2.7

    [root@svr7 Python-3.3.7rc1]# yum repolist
    已加载插件:langpacks, product-id, search-disabled-repos, subscription-manager
    This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
    源标识                              源名称                                 状态
    rhel7                               rhel7-yum                              4,620
    repolist: 4,620


关键字