[英]Python Stripe: 'module' object has no attribute 'Charge'
I have installed Stripe on my MacOSX Mavericks Macbook Pro (python 2.7) using 我已经使用以下命令在MacOSX Mavericks Macbook Pro(python 2.7)上安装了Stripe
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'
)
You have another file that is called stripe.py
, so this file is getting imported instead of the stripe
library. 您有被称为另一个文件
stripe.py
,所以这个文件得到进口代替stripe
库。
Here's how you fix this: 解决方法如下:
stripe.py
file to something different stripe.py
文件为其他名称 stripe.pyc
if it exists (mind the c
) stripe.pyc
如果存在)(注意c
) Said file is on your desktop: /Users/sebastian/Desktop/stripe.py
. 该文件在您的桌面上:
/Users/sebastian/Desktop/stripe.py
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.