天哪,这令人沮丧吗...
我通过从 httplib2我的 CentOS 开发虚拟机上的 ="nofollow">站点。在花了 1/2 天让它进行双向 ssl 身份验证后,我在目标 RHEL 5.7 计算机上安装了 python26-httplib2.noarch。由于类构造函数不同,代码突然无法运行!
官方文档定义了 Http类如下:
class httplib2.Http([cache=None][, timeout=None][, proxy_info=None][,
ca_certs=无][,disable_ssl_certificate_validation=False])
我使用 tar 安装的代码确实做到了这一点,并且它有效:
client = httplib2.Http(ca_certs='/path-to/ca.cert')
但是,在 RPM 安装中无法识别 ca_cert
参数。查看库,我确实看到以下内容:
class Http(object):
def __init__(self, cache=None, timeout=None, proxy_info=None):
即完全不同的参数列表。
对此有什么解释吗?
附言。抱歉,如果我听起来很愤怒——我确实很愤怒。现在是晚上 8 点,我希望今天签入代码...
聚苯硫醚。 Python 2.6
Boy, is this frustrating...
I installed the httplib2
by downloading the .tar.gz package from the site on my CentOS development VM. After spending 1/2 day to get it do two-way ssl authentication, I install the python26-httplib2.noarch
on the target RHEL 5.7 machine. Suddenly the code does not run as the class constructor is different!
The official documentation defines the Http
class as follows:
class httplib2.Http([cache=None][, timeout=None][, proxy_info=None][,
ca_certs=None][, disable_ssl_certificate_validation=False])
My code that uses the tar installation indeed does this, and it works:
client = httplib2.Http(ca_certs='/path-to/ca.cert')
However, the ca_cert
parameter is not recognized in the RPM installation. Looking in the lib, I indeed see the following:
class Http(object):
def __init__(self, cache=None, timeout=None, proxy_info=None):
i.e. totally different parameter list.
Is there any explanation for this?
PS. Sorry if I sound furious - I am. It's 8pm and I hoped to check in the code today...
PPS. Python 2.6
发布评论
评论(1)
我猜想:不同的 httplib2 版本。据我了解,通过快速浏览更改日志和代码,
ca_certs
支持 SSL 服务器证书验证,该验证已在 httplib2 0.7.0 中添加。来自 RPM 的 httplib2 版本是否可能比该版本更旧?print httplib2.__version__
显示什么?作为解决方法,我建议不要从 tar.gz 文件或 Red Hat 软件包安装 Python 库;使用 pip 代替,可能带有一个要求文件,您可以在其中指定确切的版本号(甚至是程序运行所需的每个外部库的下限之一)。
I would guess: different httplib2 versions. As far as I understand from a quick glance at the change log and code,
ca_certs
supports SSL server certificate validation, which has been added in httplib2 0.7.0. Is it possible that the httplib2 version coming from RPM is older than that? What doesprint httplib2.__version__
show?As a workaround, I would suggest not to install Python libraries from tar.gz files or from Red Hat packages; use pip instead, possibly with a requirement file where you can specify the exact version number (or even a lower-bound one) of each external library you need for your program to run.