华为OpenEuler体验系列(14)-编译安装python3.8.6 以及 python3.9.0

之所以安装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的使用。

九、上几张插图

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述


© 著作权归作者所有

  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

mengyoufengyu

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值