• linux系统安装Python 3.7.x


     1. 基础环境。

    [root@monitor ~]# cat /etc/redhat-release 
    CentOS Linux release 7.6.1810 (Core) 
    

     2. 升级openssl。CentOS 7.6默认自带的openssl是1.0.2,需要升级到1.1.1,否则使用pip安装模块是会报错“pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available”。(如果是先装的Python,后升级的openssl,则升级完后需要重新编译Python)

    [root@monitor ~]# openssl version
    OpenSSL 1.0.2k-fips  26 Jan 2017
    # 安装依赖。如果是CentOS 6.x的系统需要安装xz,否则下面解压Python压缩包会报错。
    [root@monitor ~]# yum -y install gcc xz
    # 下载新版本的openssl
    [root@monitor ~]# cd /usr/local/src
    [root@monitor src]# wget https://www.openssl.org/source/openssl-1.1.1c.tar.gz
    [root@monitor src]# tar xf openssl-1.1.1c.tar.gz
    [root@monitor src]# cd openssl-1.1.1c/
    [root@monitor openssl-1.1.1c]# ./config --prefix=/usr/local/openssl
    [root@monitor openssl-1.1.1c]# make
    [root@monitor openssl-1.1.1c]# make install
    # 备份原来的openssl,并为新版本的openssl创建软链接。
    [root@monitor openssl-1.1.1c]# mv /usr/bin/openssl{,.bak}
    [root@monitor openssl-1.1.1c]# ln -s /usr/local/openssl/include/openssl /usr/include/openssl
    [root@monitor openssl-1.1.1c]# ln -s /usr/local/openssl/lib/libssl.so.1.1 /usr/local/lib64/libssl.so
    [root@monitor openssl-1.1.1c]# ln -s /usr/local/openssl/bin/openssl /usr/bin/openssl
    # 写入openssl库文件的搜索路径,并使之生效。
    [root@monitor openssl-1.1.1c]# echo "/usr/local/openssl/lib" >>/etc/ld.so.conf
    [root@monitor openssl-1.1.1c]# ldconfig -v
    [root@monitor openssl-1.1.1c]# openssl version
    OpenSSL 1.1.1c  28 May 2019
    

     3. 下载Python 3.7.x的tar包,并解压。

    [root@monitor openssl-1.1.1c]# cd /usr/local/src/
    [root@monitor src]# wget https://www.python.org/ftp/python/3.7.2/Python-3.7.2.tar.xz
    [root@monitor src]# tar xf Python-3.7.2.tar.xz
    [root@monitor src]# cd Python-3.7.2/
    

     4. 编译安装。

    # 安装依赖包。
    [root@monitor Python-3.7.2]# yum -y install zlib-devel libffi-devel
    [root@monitor Python-3.7.2]# ./configure --prefix=/usr/local/python3 --with-openssl=/usr/local/openssl
    [root@monitor Python-3.7.2]# make && make install
    Successfully installed pip-18.1 setuptools-40.6.2
    

     5. 配置环境变量。

    [root@monitor python3]# cd /usr/local/python3/bin/
    [root@monitor bin]# ln -s /usr/local/python3/bin/python3 /usr/bin/python3
    [root@monitor bin]# echo 'export PATH=/usr/local/python3/bin/:$PATH' >>/etc/profile
    [root@monitor bin]# . /etc/profile
    [root@monitor bin]# python3 -V
    Python 3.7.2
    

     6. 测试pip安装requests模块。

    [root@monitor bin]# pip3 install requests
    Successfully installed certifi-2019.6.16 chardet-3.0.4 idna-2.8 requests-2.22.0 urllib3-1.25.3
    


    写作不易,转载请注明出处,谢谢~~

  • 相关阅读:
    Error: could not open `C:Program FilesJavajre6libi386jvm.cfg'
    异常:java.lang.IllegalStateException: Ambiguous handler methods mapped for HTTP path '/app/userInfoMaint/getProvince.do'
    解析Java反射
    Cause: java.sql.SQLException: 无效的列索引
    Internet Explorer 无法打开该 Internet 站点,请求的站点不可用或无法找到
    解决The JSP specification requires that an attribute name is preceded by whitespace问题
    pl/sql的to_char和to_date
    oracle 在xml中批量插入,批量修改及多组条件查询
    时间转换模板
    Java网络编程从入门到精通(5):使用InetAddress类的getHostName方法获得域名
  • 原文地址:https://www.cnblogs.com/ccbloom/p/11478056.html
Copyright © 2020-2023  润新知