【发布时间】:2012-11-07 22:28:58
【问题描述】:
我正在尝试使用以下代码从网站获取图像:
image="http://the.site.com/view/ashx/Handler.ashx?Command=Avatar&TC=TQB"
curlobj = pycurl.Curl()
curlobj.setopt(pycurl.COOKIEFILE, '')
curlobj.setopt(pycurl.CONNECTTIMEOUT, 30)
curlobj.setopt(pycurl.TIMEOUT, 30)
curlobj.setopt(pycurl.FAILONERROR, True)
curlobj.setopt(pycurl.FOLLOWLOCATION, 1)
curlobj.setopt(pycurl.MAXREDIRS, 5)
imgf = open("logo.jpg", "wb")
curlobj.setopt(pycurl.URL, image)
curlobj.setopt(pycurl.WRITEDATA, imgf)
curlobj.perform()
imgf.close()
curlobj.close()
但它给出了:
python2`.6: src/pycurl.c:272: get_thread_state: Assertion `self->ob_type == p_Curl_Type' failed.`
有什么问题?
谢谢
【问题讨论】:
-
您在哪一行收到此错误?您是如何安装 pycurl(以及 libcurl 和 python,如果它们没有内置在您的系统中)?还有哪些版本?
-
@abarnert:它不会引发异常并且不会给出行!只有这个错误;但使用调试器它发生在
.perform()行;我从 Ubuntu 的存储库(Lucid Lynx 上的版本 7.19.0-3)安装了 pycurl,并且在 Ubuntu 上预装了 python(版本 2.6.5)。libcurl是 7.19.7