centos6安装python3.6.4

Posted music378

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了centos6安装python3.6.4相关的知识,希望对你有一定的参考价值。

安装Python依赖包:

[[email protected] src]# yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make

下载Python源码包:

    [[email protected] src]# wget ttp://mirrors.sohu.com/python/3.6.4/Python-3.6.4.tgz

编译、安装:

    [[email protected] /]# tar -xzvf /usr/local/src/Python-3.6.4.tgz -C /usr/local/src/
    [[email protected] /]# cd /usr/local/src/Python-3.6.4
    [[email protected] Python-3.6.4]# ./configure --prefix=/usr/local/python
    [[email protected] Python-3.6.4]# make -j 4
    [[email protected] Python-3.6.4]# make install

查看扩展安装包:

    [[email protected] /]# /usr/local/python/bin/pip3 list
    pip (8.1.1) setuptools (20.10.1)

添加Python命令到环境变量:

[[email protected] /]# vim ~/.bash_profile

    PATH=$PATH:$HOME/bin
    改为:
    PATH=$PATH:$HOME/bin:/usr/local/python/bin

使环境变量生效:

[[email protected] /]# source ~/.bash_profile

查看Python版本:

    [[email protected] /]# python3 -V
    Python 3.6.4

更改系统默认python版本为Python3.6

[[email protected] /]# mv /usr/bin/python /usr/bin/python2.6
    [[email protected] /]# ln -s /usr/local/python/bin/python3.6 /usr/bin/python

核对Python版本:

[[email protected] /]# python -V
    Python 3.6.4

解决python升级后,YUM不能正常工作的问题:

#vi /usr/bin/yum

   将文件头部的   #!/usr/bin/python
  改成   #!/usr/bin/python2.6


以上是关于centos6安装python3.6.4的主要内容,如果未能解决你的问题,请参考以下文章

Linux下安装Python3.6.4步骤

CentOS 7下安装Python3.6.4

python3.6.4 tkinter安装

05 Windows安装python3.6.4+pycharm环境

CentOS7下安装Python3.6.4

windows 10 64位安装Python3.6.4