Pi 3B+编译安装python3.6.8

树莓派镜像版本2018-11-13,更新到2019-01-09

sudo apt-get update
sudo apt-get upgrade

 

sudo apt-get install build-essential tk-dev libncurses5-dev libncursesw5-dev libreadline6-dev libdb5.3-dev libgdbm-dev libsqlite3-dev libssl-dev libbz2-dev libexpat1-dev liblzma-dev zlib1g-dev

 

wget https://www.python.org/ftp/python/3.6.8/Python-3.6.8.tar.xz
tar xf Python-3.6.8.tar.xz

 

cd Python-3.6.8
./configure --with-ssl
make
sudo make install

 

如果参数--with-ssl无效使用进行下面操作后重新编译,据说3.6.5的--with-ssl参数无效

sudo nano Python-3.6.8/Modules/Setup

Ctrl+W找到下面的内容,已删除第2、7、8、9行前面#注释

1 # Socket module helper for socket(2)
2 _socket socketmodule.c
3 
4 # Socket module helper for SSL support; you must comment out the other
5 # socket line above, and possibly edit the SSL variable:
6 #SSL=/usr/local/ssl
7 _ssl _ssl.c \
8        -DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \
9        -L$(SSL)/lib -lssl -lcrypto

Ctrl+O保存,重新编译安装

cd Python-3.6.8
make
sudo make install

 

检查SSL模块

pi@raspberrypi:~ $ python3
Python 3.6.8 (default, Jan  9 2019, 11:41:44)
[GCC 6.3.0 20170516] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import ssl
>>>

 

不建议执行以下操作,会删除HA需要的部分依赖

sudo rm -r Python-3.6.8
rm Python-3.6.8.tar.xz
sudo apt-get --purge remove build-essential tk-dev
sudo apt-get --purge remove libncurses5-dev libncursesw5-dev libreadline6-dev
sudo apt-get --purge remove libdb5.3-dev libgdbm-dev libsqlite3-dev libssl-dev
sudo apt-get --purge remove libbz2-dev libexpat1-dev liblzma-dev zlib1g-dev
sudo apt-get autoremove
sudo apt-get clean

 

参考文章:

https://gist.github.com/dschep/24aa61672a2092246eaca2824400d37f

https://blog.csdn.net/qq_38154948/article/details/83988948

 

posted @ 2019-01-09 12:48  新贵  阅读(974)  评论(0编辑  收藏  举报