Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 532505
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T09:24:43+00:00 2026-05-13T09:24:43+00:00

I’m familiar with CURL in PHP but am using it for the first time

  • 0

I’m familiar with CURL in PHP but am using it for the first time in Python with pycurl.

I keep getting the error:

Exception Type:     error
Exception Value:    (2, '')

I have no idea what this could mean. Here is my code:

data = {'cmd': '_notify-synch',
        'tx': str(request.GET.get('tx')),
        'at': paypal_pdt_test
        }

post = urllib.urlencode(data)

b = StringIO.StringIO()

ch = pycurl.Curl()
ch.setopt(pycurl.URL, 'https://www.sandbox.paypal.com/cgi-bin/webscr')
ch.setopt(pycurl.POST, 1)
ch.setopt(pycurl.POSTFIELDS, post)
ch.setopt(pycurl.WRITEFUNCTION, b.write)
ch.perform()
ch.close()

The error is referring to the line ch.setopt(pycurl.POSTFIELDS, post)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T09:24:43+00:00Added an answer on May 13, 2026 at 9:24 am

    It would appear that your pycurl installation (or curl library) is damaged somehow. From the curl error codes documentation:

    CURLE_FAILED_INIT (2)
    Very early initialization code failed. This is likely to be an internal error or problem.
    

    You will possibly need to re-install or recompile curl or pycurl.

    However, to do a simple POST request like you’re doing, you can actually use python’s “urllib” instead of 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()
    

    to open an https:// URL, you may need to install PyOpenSSL:
    http://pypi.python.org/pypi/pyOpenSSL

    Some distibutions include this, others provide it as an extra package right through your favorite package manager.


    Edit: Have you called pycurl.global_init() yet? I still recommend urllib/urllib2 where possible, as your script will be more easily moved to other systems.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.