1. 下載python3的原碼
//安裝依賴包 yum install gcc patch libffi-devel python-devel zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel -y //下載源碼包 wget https://www.python.org/ftp/python/3.6.2/Python-3.6.2.tgz
2. 解壓縮源碼包
tar -xvf Python-3.6.2.tgz
3. 編譯文件
cd Python* //1. 釋放編譯文件makefile,這makefile就是用來編譯 ./configure --prefix=/opt/python36/ //2. 開始編譯python3 make //3. 編譯且安裝(只有在這一步,才會生成/opt/python36/) make install //4. 配置python3.6的環境變量 // 1. 配置軟鍊結 // 2. 配置path環境變量 echo $PATH查看環境變量 /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/usr/java/jdk-11.0.4/bin:/root/bin //編輯/etc/profile vim /etc/profile PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/usr/java/jdk-11.0.4/bin:/root/bin:/opt/python36/bin source /etc/profile
完成
原文地址:https://www.cnblogs.com/jbite9057/p/12075822.html
时间: 2024-10-02 04:20:07