在Linux系统中安装Python

  1. 安装依赖包;

    yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc* make -y
    
  2. 去Python官网下载需要Python3.7.8;

    wget https://www.python.org/ftp/python/3.7.8/Python-3.7.8.tgz
    
  3. 将下载下来的Python上传到Linux服务器上:/usr/local/Python3(这里的Python3文件夹是自己创建的);

  4. 将Python进行解压;

    # 切换到压缩包所在的目录
    cd /usr/local/Python3
    
    # 使用root权限进行解压
    tar zxvf Python-3.7.8
    
  5. 配置安装路径

    # 切入到解压目录
    cd /usr/local/Python3/Python-3.7.8
    # 配置安装路径
    ./configure prefix=/usr/local/python3
    
  6. 编译安装

    make && make install
    
  7. 配置软连接

    ln -s /usr/local/python3/bin/python3 /usr/bin/python3
    ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3
    
  8. 测试

    # 看是否可以运行
    python3
    pip3
    
    1. 错误一:No module named '_ctypes'

      yum install libffi-devel -y    
      cd Python-3.7.8/
      make clean && make && make install
上一篇:巧用自定义注解,一行代码搞定审计日志,你学会了吗?


下一篇:CF1028F Make Symmetrical 题解