源码安装Python

安装

安装相关依赖

apt update 
apt install -y \
    g++ gfortran iproute2 iputils-ping libbz2-dev libsqlite3-dev libblas-dev libblas3 libopenblas-dev  \
    libssl-dev libxslt1-dev libffi-dev make net-tools openssl pciutils sudo unzip vim wget xz-utils zlib1g zlib1g-dev  
apt clean

编译源码

wget https://www.python.org/ftp/python/3.7.5/Python-3.7.5.tgz --no-check-certificate -O Python-3.7.5.tgz
tar -zxvf Python-3.7.5.tgz
cd ./Python-3.7.5
./configure --prefix=/usr/local/python3.7.5 --enable-shared
make -j8
make install -j8
cp /usr/local/python3.7.5/lib/libpython3.7m.so.1.0 /usr/lib
ln -sf /usr/local/python3.7.5/bin/python3 /usr/bin/python
ln -sf /usr/local/python3.7.5/bin/python3 /usr/bin/python3
ln -sf /usr/local/python3.7.5/bin/python3 /usr/bin/python3.7
ln -sf /usr/local/python3.7.5/bin/python3 /usr/bin/python3.7.5
ln -sf /usr/local/python3.7.5/bin/pip3 /usr/bin/pip3.7
ln -sf /usr/local/python3.7.5/bin/pip3 /usr/bin/pip3.7.5
ln -sf /usr/local/python3.7.5/bin/pip3 /usr/bin/pip3
ln -sf /usr/local/python3.7.5/bin/pip3 /usr/bin/pip

FAQ

  1. 问题 subprocess.CalledProcessError: Command ‘(‘lsb_release’, ‘-a’)’ returned non-zero exit status 1

    解决方法

     find / -name lsb_release
     rm -rf /usr/bin/lsb_release
    

results matching ""

    No results matching ""