之所以安装pythonb3.8.6,是因为3.9的配套whl包不全。
一、安装开发包:
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-devel
二、安装openssl
wget http://ftp.jaist.ac.jp/pub/OpenBSD/LibreSSL/libressl-3.2.2.tar.gz
tar xzvf libressl-3.2.2.tar.gz
cd libressl-3.2.2
./configure --prefix=/usr/local/ssl
make
sudo make install
三、安装python386
export py_ver=3.8.6
wget https://www.python.org/ftp/python/${py_ver}/Python-${py_ver}.tgz
tar xzvf Python-${py_ver}.tgz
cd Python-${py_ver}
./configure --prefix=/usr/local/python${py_ver//.} --enable-optimizations --with-uuid=ossp CFLAGS=-fPIC --enable-shared
make -j4
sudo su
export py_ver=3.8.6
make install
ln -s /usr/local/python${py_ver//.}/bin/python${py_ver%.*} /usr/bin/python${py_ver}
ln -s /usr/local/python${py_ver//.}/bin/python${py_ver%.*} /usr/bin/python${py_ver//.}
ln -s /usr/local/python${py_ver//.}/bin/pip${py_ver%.*} /usr/bin/pip${py_ver}
ln -s /usr/local/python${py_ver//.}/bin/pip${py_ver%.*} /usr/bin/pip${py_ver//.}
# sudo ln -s /usr/local/python${py_ver//.}/bin/python${py_ver%.*} /usr/bin/python3
# sudo ln -s /usr/local/python${py_ver//.}/bin/pip${py_ver%.*} /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/python${py_ver//.}/lib > ./python${py_ver//.}.conf
mv ./python${py_ver//.}.conf /etc/ld.so.conf.d/
ldconfig -v
四、安装python390
export py_ver=3.9.0
wget https://www.python.org/ftp/python/${py_ver}/Python-${py_ver}.tgz
tar xzvf Python-${py_ver}.tgz
cd Python-${py_ver}
./configure --prefix=/usr/local/python${py_ver//.} --enable-optimizations --with-uuid=ossp CFLAGS=-fPIC --enable-shared
make -j4
sudo su
export py_ver=3.9.0
make install
ln -s /usr/local/python${py_ver//.}/bin/python${py_ver%.*} /usr/bin/python${py_ver}
ln -s /usr/local/python${py_ver//.}/bin/python${py_ver%.*} /usr/bin/python${py_ver//.}
ln -s /usr/local/python${py_ver//.}/bin/pip${py_ver%.*} /usr/bin/pip${py_ver}
ln -s /usr/local/python${py_ver//.}/bin/pip${py_ver%.*} /usr/bin/pip${py_ver//.}
# sudo ln -s /usr/local/python${py_ver//.}/bin/python${py_ver%.*} /usr/bin/python${py_ver%.*}
# sudo ln -s /usr/local/python${py_ver//.}/bin/pip${py_ver%.*} /usr/bin/pip${py_ver%.*}
# python3: error while loading shared libraries: libpython3.7m.so.1.0: cannot open shared object file: No such file or directory
echo /usr/local/python${py_ver//.}/lib > ./python${py_ver//.}.conf
mv ./python${py_ver//.}.conf /etc/ld.so.conf.d/
ldconfig -v
五、换华为源并添加代理
mkdir ~/.pip
cat > ~/.pip/pip.conf << EOF
[global]
index-url = http://mirrors.huaweicloud.com/repository/pypi/simple
trusted-host = mirrors.huaweicloud.com
timeout = 120
EOF
六、设置权限
sudo su
export py_ver=3.8.6
chmod 777 /usr/local/python${py_ver//.}
find /usr/local/python${py_ver//.} -type d |xargs -i chmod 777 {}
find /usr/local/python${py_ver//.} -type f |xargs -i ls -l {} |grep -E "^\-rw\-"|awk '{print $9}'|xargs -i chmod a+rw {}
chmod a+rw /usr/local/python${py_ver//.}/lib/python${py_ver%.*}/site-packages/setuptools/script*
chmod a+rw /usr/local/python${py_ver//.}/lib/python${py_ver%.*}/site-packages/setuptools/command/launcher*
find /usr/local/python${py_ver//.} -type f |xargs -i ls -l {} |grep -E "^...x.....\-"|awk '{print $9}'|xargs -i chmod a+x {}
find /usr/local/python${py_ver//.} -type f |xargs -i ls -l {} |grep -E "^..w.....\-."|awk '{print $9}'|xargs -i chmod a+w {}
find /usr/local/python${py_ver//.} -type f |xargs -i ls -l {} |grep -E "^.r.....\-.."|awk '{print $9}'|xargs -i chmod a+r {}
exit
七、升级
python386 -m pip install --upgrade pip
pip3 install --upgrade setuptools
# 设置环境变量
sudo sed -i '$a\export PATH=/usr/local/python373/bin:$PATH' /etc/bashrc
八、错误
1、源出现如下错误:
WARNING: Skipping page https://mirrors.huaweicloud.com/repository/pypi/simple/pip/ because the GET request got Content-Type: application/octet-stream.The only supported Content-Type is text/html
解决:将pip元由https协议修改为http
cat pip.conf
[global]
index-url = http://mirrors.huaweicloud.com/repository/pypi/simple
trusted-host = mirrors.huaweicloud.com
timeout = 120
至此,完成OpenEuler的中文桌面安装、博客书写、python开发的搭建。可以进行AI
学习了。下面的专题就转入该环境的Python的使用。
九、上几张插图
© 著作权归作者所有