我要评分
获取效率
正确性
完整性
易理解

Installing Python

  1. Download the source code of Python 3.7.5.
    1
    wget https://www.python.org/ftp/python/3.7.5/Python-3.7.5.tgz
    
  2. Decompress Python-3.7.5.tgz.
    1
    tar -zxvf Python-3.7.5.tgz
    
  3. Go to the Python source code directory.
    1
    cd Python-3.7.5
    
  4. Compile Python.
    1
    2
    3
    ./configure --prefix=/usr/local/python3.7 --enable-optimizations
    make
    make install
    
  5. Create a soft link file in the path of the execution file.
    1
    2
    ln -s /usr/local/python3.7/bin/python3 /usr/bin/python3
    ln -s /usr/local/python3.7/bin/pip3 /usr/bin/pip3
    
  6. Configure environment variables.
    1. Create a /etc/profile.d/python37.sh file.
      1
      vi /etc/profile.d/python37.sh
      
    2. Add the following content to the file:
      1
      2
      3
      4
      if [ -z ${PYTHON37_HOME} ]; then
      export PYTHON37_HOME=/usr/local/python3.7
      export PATH=${PYTHON37_HOME}/bin:${PATH}
      fi
      
    3. Press Esc, type :wq!, and press Enter to save the file and exit.
    4. Load the environment variables.
      1
      source /etc/profile.d/python37.sh
      
  7. Query the Python version.
    1
    python3 --version
    

    If the following information is displayed, the installation is successful: