Question

I have installed Stripe on my MacOSX Mavericks Macbook Pro (python 2.7) using

but I always get the following error message:

$ sudo python stripe.py
Traceback (most recent call last):
  File "stripe.py", line 1, in <module>
    import stripe
  File "/Users/sebastian/Desktop/stripe.py", line 7, in <module>
    resp = stripe.Charge.create(
AttributeError: 'module' object has no attribute 'Charge'

when I try to execute the following script:

import stripe

stripe.api_key = 'my_test_secret_key'

resp = stripe.Charge.create(
    amount=200,
    currency='usd',
    card={
        'number': '4242424242424242',
        'exp_month': 10,
        'exp_year': 2014
    },
    description='customer@gmail.com'
)
Was it helpful?

Solution

You have another file that is called stripe.py, so this file is getting imported instead of the stripe library.

Here's how you fix this:

  • Rename your stripe.py file to something different
  • Remove stripe.pyc if it exists (mind the c)

Said file is on your desktop: /Users/sebastian/Desktop/stripe.py.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top