ubuntu18.04编译安装python3.8

下载

1
2
3
4
5
# 下载源码包至`opt`目录
wget -c -P /opt https://www.python.org/ftp/python/3.8.0/Python-3.8.0.tar.xz
# 解压解包
tar - xvf Python-3.8.0.tar.xz
cd Python-3.8.0

编译安装

1
2
3
4
5
6
7
8
9
10
# 更新系统
apt-get update
apt-get upgrade
apt-get dist-upgrade
# 安装依赖库
apt-get install libbz2-dev libncurses5-dev libgdbm-dev libgdbm-compat-dev liblzma-dev libsqlite3-dev libssl-dev openssl tk-dev uuid-dev libreadline-dev python-dev

./configure --enable-optimizations --enable-shared
make -j8
make altinstall

运行测试

1
2
python3.8
# python3.8: error while loading shared libraries: libpython3.8.so.1.0: cannot open shared object file: No such file or directory

配置动态链接库路径

1
2
3
4
5
6
7
vim ~/.profile
# 追加
export LD_LIBRARY_PATH="/usr/local/lib"
alias python="/usr/local/bin/python3.8"
alias python3.8="/usr/local/bin/python3.8"
# 更新
source ~/.profile

再次测试成功!

文章作者: Spaceack
文章链接: http://spaceack.com/2019/11/18/2019-11-18-ubuntu18-04%E7%BC%96%E8%AF%91%E5%AE%89%E8%A3%85python3-8/
版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 丸子家的小云吞
支付宝打赏
微信打赏