如何在Debian Linux上为Python 2.5安装SSL?

4 投票
2 回答
5224 浏览
提问于 2025-04-16 01:15

问题

我该如何在Debian上为Python 2.5安装SSL?

我试过:

sudo easy_install ssl

但是出现了:

$ python setup.py build
looking for /usr/include/openssl/ssl.h
looking for /usr/include/krb5.h
running build
running build_py
running build_ext
building 'ssl._ssl2' extension
creating build/temp.linux-i686-2.5
creating build/temp.linux-i686-2.5/ssl
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I./ssl/2.5.1 -I/usr/include/python2.5 -c ssl/_ssl2.c -o build/temp.linux-i686-2.5/ssl/_ssl2.o
In file included from ssl/_ssl2.c:75:
./ssl/2.5.1/socketmodule.h:45:33: error: bluetooth/bluetooth.h: No such file or directory
./ssl/2.5.1/socketmodule.h:46:30: error: bluetooth/rfcomm.h: No such file or directory
./ssl/2.5.1/socketmodule.h:47:29: error: bluetooth/l2cap.h: No such file or directory
./ssl/2.5.1/socketmodule.h:48:27: error: bluetooth/sco.h: No such file or directory
In file included from ssl/_ssl2.c:75:
./ssl/2.5.1/socketmodule.h:98: error: field ‘bt_l2’ has incomplete type
./ssl/2.5.1/socketmodule.h:99: error: field ‘bt_rc’ has incomplete type
./ssl/2.5.1/socketmodule.h:100: error: field ‘bt_sco’ has incomplete type
error: command 'gcc' failed with exit status 1

解决方案

sudo apt-get install libbluetooth-dev
sudo rm /usr/lib/python2.5/site-packages/ssl/__init__.pyc 

2 个回答

1

其实,你不应该自己编译 Python 的 ssl 模块,原因有几个:

  • 你不会自动收到 Python ssl 模块的安全更新;
  • 如果你决定升级服务器上的 Debian 系统,升级过程会很麻烦。

获取 Python ssl 模块的最佳方法是通过官方的 Debian 软件库,用 apt-get 安装:

apt-get install python-openssl

希望这些信息对你有帮助。

8

作为参考,你需要安装 libbluetooth-dev

撰写回答