我使用
在我的MacOSX Mavericks Macbook Pro(python 2.7)上安装了 Stripe但我总是收到以下错误消息:
$ 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'
当我尝试执行以下脚本时:
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'
)
答案 0 :(得分:6)
您有另一个名为stripe.py
的文件,因此导入此文件而不是stripe
库。
以下是解决此问题的方法:
stripe.py
文件重命名为不同的文件stripe.pyc
(如果它存在(请注意c
)所述文件位于您的桌面上:/Users/sebastian/Desktop/stripe.py
。