SSL 和 Tkinter 不存在于 Python 3.5.2、Debian Linux 的源代码构建中

2024-05-03

我刚刚将 Python 3.5.2 下载到我的 Debian 机器上并使用以下命令构建它:

./configure 
make
make test
sudo make install

一切正常,但在make test输出中,它显示安装程序由于未安装模块 _tkinter 和 _ssl 而跳过了某些测试。此外,缺少 SSL 使我无法使用 pip。这也发生在我的 3.5.1 版本上,但我认为这只是一个早期的、有缺陷的版本。我怎样才能解决这个问题?我特别需要 SSL 来发送电子邮件。


由于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.

有用的链接:

  1. 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

  2. 导入错误:没有名为 _ssl 的模块 https://stackoverflow.com/questions/5128845/importerror-no-module-named-ssl

  3. http://bugs.python.org/issue12876 http://bugs.python.org/issue12876

  4. 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
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

SSL 和 Tkinter 不存在于 Python 3.5.2、Debian Linux 的源代码构建中 的相关文章

随机推荐