由于Python(正确的名称是CPython,因为还存在Cython、Jython、PyPy等),您需要为其构建所有依赖项。
$ sudo apt-get update
# Required dependencies
$ sudo apt-get install build-essential
# Optional dependencies
$ sudo apt-get install libbz2-dev libgdbm-dev libsqlite3-dev libreadline6-dev libncurses5-dev libssl-dev zlib1g-dev liblzma-dev tk-dev
从源代码安装Python3.5后,尝试导入带有“C依赖项”的模块(如果没有错误,那么Python3.5已安装完整功能)
$python3
Python 3.5.2 (default, Dec 27 2016, 17:04:10)
[GCC 4.9.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sqlite3
>>> import tkinter
>>> import ssl
Debian 8 默认有 Python2.7 和 Python3.4。所以安装Python后你将拥有三个版本的Python。
$ python -c "import sys; print('Installed python %s' % sys.version[:6])" ; python3.4 -c "import sys; print('Installed python %s' % sys.version[:6])" ; python3.5 -c "import sys; print('Installed python %s' % sys.version[:6])"
Installed python 2.7.9
Installed python 3.4.2
Installed python 3.5.2
在 Debian 9 中,Python 3.5 将作为默认版本 Python3https://packages.debian.org/search?keywords=python3.5 https://packages.debian.org/search?keywords=python3.5.
有用的链接:
https://askubuntu.com/questions/21547/what-are-the-packages-libraries-i-should-install-before-compiling-python-from-so https://askubuntu.com/questions/21547/what-are-the-packages-libraries-i-should-install-before-compiling-python-from-so
导入错误:没有名为 _ssl 的模块 https://stackoverflow.com/questions/5128845/importerror-no-module-named-ssl
http://bugs.python.org/issue12876 http://bugs.python.org/issue12876
http://www.simplydjango.com/python-on-ubuntu/ http://www.simplydjango.com/python-on-ubuntu/
测试环境
$ uname -a
Linux localhost 3.16.0-4-amd64 #1 SMP Debian 3.16.36-1+deb8u2 (2016-10-19) x86_64 GNU/Linux
$ lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux 8.6 (jessie)
Release: 8.6
Codename: jessie