zoukankan      html  css  js  c++  java
  • Linux下安装Python3

    一、安装python3.6

    1. 安装依赖环境

      # yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel

    2.下载Python3
      https://www.python.org/downloads/

    1
    # wget https://www.python.org/ftp/python/3.6.1/Python-3.6.1.tgz

    3.安装python3

      我个人习惯安装在/usr/local/python3(具体安装位置看个人喜好)
      创建目录:

    1
    # mkdir -p /usr/local/python3

      解压下载好的Python-3.x.x.tgz包(具体包名因你下载的Python具体版本不不同⽽而不不同,如:我下载的是Python3.6.1.那我这里就是Python-3.6.1.tgz)

    1
    # tar -zxvf Python-3.6.1.tgz

    4.进入解压后的目录,编译安装。

    1
    2
    # cd Python-3.6.1
    # ./configure --prefix=/usr/local/python3

      

    如果出现:no acceptable C compiler found in $PATH

    那么说明需要安装gcc

    yum install gcc

    然后:./configure --prefix=/usr/local/python3

    make

    make install

    5.建立python3的软链

    ln -s /usr/local/python3/bin/python3 /usr/bin/python3

    6.并将/usr/local/python3/bin加入PATH

    1 # vim ~/.bash_profile
    2 # .bash_profile
    3 # Get the aliases and functions
    4 if [ -f ~/.bashrc ]; then
    5 . ~/.bashrc
    6 fi
    7 # User specific environment and startup programs
    8 PATH=$PATH:$HOME/bin:/usr/local/python3/bin
    9 export PATH

    按ESC,输入:wq回车退出。

      修改完记得执行行下面的命令,让上一步的修改生效:

    source ~/.bash_profile

    检查Python3及pip3是否正常可用:

    1 # python3 -V
    2 Python 3.6.1
    3 # pip3 -V
    4 pip 9.0.1 from /usr/local/python3/lib/python3.6/site-packages (python 3.6)

    7.不行的话在创建一下pip3的软链接

    1 ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3
  • 相关阅读:
    [五]SpringMvc学习-Restful风格实现
    [四]SpringMvc学习-对servlet与json的支持与实现
    [三]SpringMvc学习-封装、乱码问题、重定向、转发
    Android-aidl, binder,surfaceview
    linux memory dump--http://www.forensicswiki.org/wiki/Tools:Memory_Imaging
    Vanish/squid
    dongle --NFC
    词频统计 in office
    各种小巧的Hello World
    程序入口函数和glibc及C++全局构造和析构
  • 原文地址:https://www.cnblogs.com/shaowentao/p/10193134.html
Copyright © 2011-2022 走看看