urllib2.URLError: <urlopen error unknown url type: https>

来源:互联网 发布:cf手游版刷枪软件下载 编辑:程序博客网 时间:2024/06/07 23:11

升级 python 版本后,使用 python 可能会出现以下报错

urllib2.URLError: <urlopen error unknown url type: https>

因为编译 python 的时候没有把 ssl模块 编译进去,只需修改 Modules/Setup文件 重新编译安装即可。

进入python安装包,找到Setup文件,用 vi 打开

cd Python-2.7.3/Modulesvi Setup

找到

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

把前面的 # 号去掉,修改为

# Socket module helper for SSL support; you must comment out the other# socket line above, and possibly edit the SSL variable:SSL=/usr/local/ssl_ssl _ssl.c \       -DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \       -L$(SSL)/lib -lssl -lcrypto

保存退出,重新编译安装

./configure --prefix=/usr/local/python2.7 make && make install

完成,漂亮~




1 0
原创粉丝点击