谷姐:我们都是谷歌迷
We are all Google fans

Debian 8/9编译安装Python 3.6

发现Debian 8/9自带的Python2.7和Python3.5很多地方不能用了,试着手动编译安装Python 3.6,同时为了试下新装的代码高亮插件WP-GeSHi-Highlight,记录下安装过程!

1. 安装依赖

sudo apt update
sudo apt-get install -y make build-essential libssl-dev zlib1g-dev libbz2-dev \
libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev \
xz-utils tk-dev libffi-dev liblzma-dev

如果libreadline-dev找不到,就安装libedit-dev

sudo apt install libedit-dev

2. 下载、编译安装Python 3.6

wget https://www.python.org/ftp/python/3.6.9/Python-3.6.9.tgz
tar xvf Python-3.6.9.tgz
cd Python-3.6.9
./configure --enable-optimizations --enable-shared --with-ensurepip=install
make -j8
sudo make altinstall

其他版本的Python下载地址: https://www.python.org/ftp/python/

3. 检查是否能用

python3.6 --version
Python 3.6.9

如果报错

python3.6: error while loading shared libraries: libpython3.6m.so.1.0: cannot open shared object file: No such file or directory>

是说静态库文件没找到,其实这个静态库文件就在我们下载的源码里面,一般这样做

cp libpython3.6m.so.1.0 /usr/local/lib/python3.6/
cat "export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib/python3.6" >> ~/.bashrc && source ~/.bashrc

4. 完成!

当然除了编译安装Python 3.6,还有别的选择,比如从test源中安装预编译好的

sudo echo "deb http://ftp.fr.debian.org/debian testing main" >> /etc/apt/sources.list
sudo apt-get update
sudo apt-get install -y python3.6

或者直接将系统升级到最新的Debian 10,因为该发行版本直接支持Python 3.7 :)

5 1 vote
Article Rating
 收藏 (0) 打赏

您可以选择一种方式赞助本站

支付宝扫一扫赞助

微信钱包扫描赞助

未经允许不得转载:谷姐靓号网 » Debian 8/9编译安装Python 3.6

Subscribe
提醒
guest
0 评论
Inline Feedbacks
View all comments

买Google Voice认准【谷姐靓号网】

Google Voice靓号列表Google Voice自助购买
切换注册

登录

忘记密码 ?

切换登录

注册

我们将发送一封验证邮件至你的邮箱, 请正确填写以完成账号注册和激活

0
Would love your thoughts, please comment.x
()
x