以严谨的方式安装python

in 读书学习 with 0 comment

以严谨的方式安装python

这里以Centos8.0安装python3.7.8为例

  1. wget https://npm.taobao.org/mirrors/python/3.7.8/Python-3.7.8.tar.xz #用阿里云的镜像下载Python
  2. xz -d Python-3.7.8.tar.xz && tar -xvf Python-3.7.8.tar #解压安装包
  3. cd Python-3.7.8
  4. ./configure --prefix=/usr/local/python3 --enable-shared CFLAGS=-fPIC
  5. make && make install

这里完成之后出现了如下警告

WARNING: The script easy_install-3.7 is installed in '/usr/local/python3/bin' which is not on PATH. Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location. WARNING: The scripts pip3 and pip3.7 are installed in '/usr/local/python3/bin' which is not on PATH. Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.

提示我们需要建立软连接

ln -s /usr/local/python3/bin/python3 /usr/bin/python3
ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3

到这里应该是可以结束了,不过有可能会找不到“libpython3.7m.so*”这类文件,之后这样处理就行:

cd /etc/ld.so.conf.d && vi python3.conf
/usr/local/python3/lib
wq!
ldconfig