源码安装python3

Debian9:

$ sudo apt update
$ sudo apt install build-essential libbz2-dev libssl-dev libncurses5-dev libsqlite3-dev libreadline-dev tk-dev libgdbm-dev libdb-dev libpcap-dev xz-utils libexpat1-dev  liblzma-dev libffi-dev libc6-dev

Centos7:

# yum groupinstall "Development tools"
# yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel libffi-devel

下载安装:

$ curl -O https://www.python.org/ftp/python/3.7.3/Python-3.7.3.tar.xz
$ tar xJf Python-3.7.3.tar.xz
$ cd Python-3.7.3
$ ./configure  --with-ssl --enable-optimization

  --enable-optimaizaions : 运行多个测试来优化Python二进制文件,这将使构建过程变慢

  --prefix=/usr/local/python3.6

编译安装:

$ make -j 8
$ sudo make altinstall

  为了缩短构建时间,需要根据处理器修改-j标志。如果不知道处理器的核心数量,可以通过键入nproc来找到它。本文以8个内核为例,则使用的是-j8标志。

 make install 会覆盖系统的python3

 python3安装PyQt4

sudo apt install python3-pyqt4 libcanberra-gtk-module

 

posted @ 2019-07-28 22:54  少侠不懂天文  阅读(72)  评论(0编辑  收藏  举报