凉城旧巷
Python从入门到自闭,Java从自闭到放弃,数据库从删库到跑路,Linux从rm -rf到完犊子!!!

Linux编译安装Python3.6.8

一、下载源码包

官网链接:https://www.python.org/downloads/source/

下载gzipped source tarball

 

二、依赖安装

yum install -y zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make libffi-devel

 

三、编译安装

tar -zxvf Python-3.6.8.tgz

cd Python-3.6.8/

./configure --prefix=/data/python-3.6.8 --with-openssl=/usr/local/openssl

make

make install

 

四、添加到环境变量

方式一:

vim /etc/profile.d/custom.sh

export PATH=/data/python-3.6.8/bin:$PATH

 

csh版:

vim /etc/profile.d/custom.csh

setenv PATH /data/python-3.6.8/bin:$PATH

 

方式二:

ln -s /data/python-3.6.8/bin/python3.6 /usr/bin/python3  #添加python3的软链接 
ln -s /data/python-3.6.8/bin/pip3.6 /usr/bin/pip3        #添加 pip3 的软链接 
ln -s /data/python-3.6.8/bin/pip3.6 /usr/bin/pip         #添加 pip 的软链接 
  • 如果提示

    ln: failed to create symbolic link ‘/usr/bin/python3’: File exists
    ln: failed to create symbolic link ‘/usr/bin/pip3’: File exists
    
    • 删除原有软链接

      rm -rf /usr/bin/python3
      ln -s /data/python-3.6.8/bin/python3.6 /usr/bin/python3
      rm -rf /usr/bin/pip3
      ln -s /data/python-3.6.8/bin/pip3.6 /usr/bin/pip3
      ln -s /data/python-3.6.8/bin/pip3.6 /usr/bin/pip
      
posted on 2022-06-22 09:40  凉城旧巷  阅读(362)  评论(0编辑  收藏  举报