Может показаться, что ваша установка pycurl (или библиотека curl) как-то повреждена. Из документации кодов ошибок curl:
CURLE_FAILED_INIT (2)
Very early initialization code failed. This is likely to be an internal error or problem.
Возможно, вам потребуется переустановить или перекомпилировать curl или pycurl.
Однако, чтобы сделать простой POST-запрос, как вы делаете, вы можете использовать pyll "urllib" вместо CURL:
import urllib
postdata = urllib.urlencode(data)
resp = urllib.urlopen('https://www.sandbox.paypal.com/cgi-bin/webscr', data=postdata)
# resp is a file-like object, which means you can iterate it,
# or read the whole thing into a string
output = resp.read()
# resp.code returns the HTTP response code
print resp.code # 200
# resp has other useful data, .info() returns a httplib.HTTPMessage
http_message = resp.info()
print http_message['content-length'] # '1536' or the like
print http_message.type # 'text/html' or the like
print http_message.typeheader # 'text/html; charset=UTF-8' or the like
# Make sure to close
resp.close()
, чтобы открыть https://
URL, вам может потребоваться установить PyOpenSSL:
http://pypi.python.org/pypi/pyOpenSSL
Некоторые дистрибутивы включают это, другие предоставляют его как дополнительный пакет прямо через ваш любимый менеджер пакетов.
Редактировать: Вы уже позвонили pycurl.global_init () еще? Я по-прежнему рекомендую urllib / urllib2, где это возможно, так как ваш скрипт будет легче переносить в другие системы.