一、安装开发包:
yum -y install zlib zlib-devel bzip2-devel openssl-devel
yum -y install ncurses-devel sqlite-devel readline-devel
yum -y install tk-devel gdbm-devel wget xz-devel
yum -y install gcc kernel-devel make bzip2 libffi libffi-devel
yum -y install expat-devel e2fsprogs-devel libuuid-devel tcl
yum -y install gdbm-devel tcl-devel tk-devel
二、关于uuid-level有两种方案
1、安装centos的包:
wget https://mirrors.huaweicloud.com/centos/7/os/x86_64/Packages/uuid-devel-1.6.2-26.el7.x86_64.rpm
yum install uuid-devel-1.6.2-26.el7.x86_64.rpm
2、根据上面的包重新打包为euler的包
yum install uuid-devel-1.6.2-26.eulerosv2r7.x86_64.rpm
三、安装openssl
wget http://ftp.jaist.ac.jp/pub/OpenBSD/LibreSSL/libressl-2.9.2.tar.gz
tar xzvf libressl-2.9.2.tar.gz
cd libressl-2.9.2
./configure --prefix=/usr/local/ssl
make
sudo make install
四、安装python373
wget https://www.python.org/ftp/python/3.7.3/Python-3.7.3.tgz
tar xzvf Python-3.7.3.tgz
cd Python-3.7.3
sed -i "6s/endif/else/" ./Modules/_uuidmodule.c
sed -i "7d" ./Modules/_uuidmodule.c
sed -i "s/Werror=implicit-function-declaration/Wno-error/g" ./configure
./configure --prefix=/usr/local/python373 --enable-optimizations --with-uuid=ossp CFLAGS=-fPIC --enable-shared
make -j4
sudo make install
sudo ln -s /usr/local/python373/bin/python3.7 /usr/bin/python3.7.3
sudo ln -s /usr/local/python373/bin/python3.7 /usr/bin/python373
sudo ln -s /usr/local/python373/bin/pip3.7 /usr/bin/pip3.7.3
sudo ln -s /usr/local/python373/bin/pip3.7 /usr/bin/pip373
sudo ln -s /usr/local/python373/bin/python3.7 /usr/bin/python3
sudo ln -s /usr/local/python373/bin/pip3.7 /usr/bin/pip3
# python3: error while loading shared libraries: libpython3.7m.so.1.0: cannot open shared object file: No such file or directory
echo /usr/local/python373/lib > ./python373.conf
sudo mv ./python373.conf /etc/ld.so.conf.d/
sudo ldconfig -v
五、换华为源并添加代理
mkdir ~/.pip
cat > ~/.pip/pip.conf << EOF
[global]
index-url = https://mirrors.huaweicloud.com/repository/pypi/simple
trusted-host = mirrors.huaweicloud.com
timeout = 120
proxy = http://10.0.2.2:3128
EOF
六、设置权限
sudo su
chmod 777 /usr/local/python373
find /usr/local/python373 -type d |xargs -i chmod 777 {}
find /usr/local/python373 -type f |xargs -i ls -l {} |grep -E "^\-rw\-"|awk '{print $9}'|xargs -i chmod a+rw {}
chmod a+rw /usr/local/python373/lib/python3.7/site-packages/setuptools/script*
chmod a+rw /usr/local/python373/lib/python3.7/site-packages/setuptools/command/launcher*
find /usr/local/python373 -type f |xargs -i ls -l {} |grep -E "^...x.....\-"|awk '{print $9}'|xargs -i chmod a+x {}
find /usr/local/python373 -type f |xargs -i ls -l {} |grep -E "^..w.....\-."|awk '{print $9}'|xargs -i chmod a+w {}
find /usr/local/python373 -type f |xargs -i ls -l {} |grep -E "^.r.....\-.."|awk '{print $9}'|xargs -i chmod a+r {}
exit
七、升级
python3 -m pip install --upgrade pip
pip3 install --upgrade setuptools
# 设置环境变量
sudo sed -i '$a\export PATH=/usr/local/python373/bin:$PATH' /etc/bashrc
来源:oschina
链接:https://my.oschina.net/mengyoufengyu/blog/3165441