zoukankan      html  css  js  c++  java
  • CentOS 7下安装Python3.6和pip

    一.安装python3.6

    1.1.安装python3.6需要依赖包

    yum install openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel sqlite-devel install wget gcc make -Y
    

    1.2.到python官网找到下载路径, 用wget下载

    wget https://www.python.org/ftp/python/3.6.4/Python-3.6.4.tgz
    

    1.3.解压缩

    tar -zxvf Python-3.6.4.tgz
    

    1.4.编译软件包

    先解释下上面的参数,--prefix 是预期安装目录,--enable-optimizations 是优化选项(LTO,PGO 等)加上这个 flag 编译后,性能有 10% 左右的优化(如果没记错的话),但是这会明显的增加编译时间。

    cd Python-3.6.4
     ./configure --prefix=/usr/local/python3.6 --enable-optimizations
    

    1.5.安装

     make
     make install
    

    1.6.建立软连接

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

    1.7.测试是否安装成功

    [root@host-10-0-100-173 ~]# python3
    Python 3.6.4 (default, Jun 14 2018, 13:58:35) 
    [GCC 4.8.5 20150623 (Red Hat 4.8.5-28)] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>> 
    

    二.安装pip

    2.1 yum 安装

    # 首先安装 epel 扩展源
     yum -y install epel-release
    
    # 安装 python-pip
     yum -y install python-pip
    
    # 清除 cache
     yum clean all
    

     通过这种方式貌似只能安装 pip2,想要安装 Python 3 的 pip,可以通过以下的源代码安装方式。

     2.2 源码安装

    # 下载源代码
    $ wget --no-check-certificate https://github.com/pypa/pip/archive/9.0.1.tar.gz
    解压文件
    $ tar -zvxf 9.0.1.tar.gz    # 解压文件
    
    $ cd pip-9.0.1
    
    # 使用 Python 3 安装
    $ python3 setup.py install
    创建链接:
    $ sudo ln -s /usr/local/python3/bin/pip /usr/bin/pip
    

      

      

     

      

      

      

      

     

      

      

  • 相关阅读:
    bzoj 1031: [JSOI2007]字符加密Cipher
    [BZOJ5011][JXOI2017]颜色
    [BZOJ4765]普通计算姬(分块+树状数组)
    [BZOJ3261]最大异或和(可持久化Trie)
    [BZOJ4861][BJOI2017]魔法咒语(AC自动机+矩阵优化DP)
    [BZOJ2286][SDOI2011]消耗战(虚树DP)
    [BZOJ2109][NOI2010]航空管制(贪心+拓扑)
    [BZOJ1305][CQOI2009]跳舞(网络流)
    [Nescafé41]编码病毒(循环卷积)
    [Nescafé41]异化多肽(多项式求逆元)
  • 原文地址:https://www.cnblogs.com/jimmy-xuli/p/9182822.html
Copyright © 2011-2022 走看看