zoukankan      html  css  js  c++  java
  • 源码安装Python3

    源码安装Python3

    一、安装Python3需要的依赖包

    [root@localhost ~]# yum install -y gcc make wget openssl openssl-devel readline readline-devel zlib* libffi-devel
    
    • 注释:readlinebash shell 用的库,包含许多使用功能
    • 后面预编译可能会出现zipimport.ZipImportError: can't decompress data; zlib not available报错,所以先安装zlib*(包括需要的组件)
    • 后面编译安装可能会出现出现异常ModuleNotFoundError: No module named '_ctypes'报错,所以先安装libffi-devel

    二、下载Python3源码包、安装

    1. 下载Python3源码包
    [root@localhost ~]# wget https://www.python.org/ftp/python/3.8.1/Python-3.8.1.tgz
    
    2. 解压
    [root@localhost ~]# tar -xvf Python-3.8.1.tgz
    
    3. 预编译
    [root@localhost ~]# cd Python-3.8.1
    [root@localhost Python-3.8.1]# ./configure --prefix=/usr/local/python3 --with-ssl
    
    4. 编译安装
    [root@localhsot Python-3.8.1]# make
    [root@localhsot Python-3.8.1]# make install
    

    三、启动Python3

    [root@localhost ~]# /usr/local/python3/bin/python3
    Python 3.8.1 (default, Nov 22 2020, 17:23:29) 
    [GCC 8.3.1 20191121 (Red Hat 8.3.1-5)] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>> 
    

    测试是否可以使用ssl模块

    [root@localhost ~]# python3 
    Python 3.8.1 (default, Nov 22 2020, 17:23:29) 
    [GCC 8.3.1 20191121 (Red Hat 8.3.1-5)] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import ssl
    >>>        //没有回显什么,表示可以使用ssl模块
    

    四、快速启动

    在/usr/bin路径下生成Python3的软链接:ln -s /usr/local/python3/bin/python3 /usr/bin/python3
    [root@localhost ~]# ln -s /usr/local/python3/bin/python3 /usr/bin/python3
    [root@localhost ~]# python3 
    Python 3.8.1 (default, Nov 22 2020, 17:23:29) 
    [GCC 8.3.1 20191121 (Red Hat 8.3.1-5)] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>> 
    [root@localhost ~]#
    [root@localhost ~]# which python3 
    /usr/bin/python3
    
  • 相关阅读:
    用循环链表求解约瑟夫问题
    Nim游戏变种——取纽扣游戏
    POJ-2726-Holiday Hotel
    常用排序算法总结(二)
    常用排序算法总结(一)
    找出数组中出现次数最多的那个数——主元素问题
    C99新特性:变长数组(VLA)
    linux tftp配置 (Ubuntu18.04)
    Ubuntu 18.04安装Samba服务器及配置
    记录学习Linux遇到的问题
  • 原文地址:https://www.cnblogs.com/itwangqiang/p/14018865.html
Copyright © 2011-2022 走看看