Python Stripe:“模块"对象没有属性“收费" [英] Python Stripe: 'module' object has no attribute 'Charge'
本文介绍了Python Stripe:“模块"对象没有属性“收费"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经使用以下软件在我的MacOSX Mavericks Macbook Pro(python 2.7)上安装了 Stripe .>
- pip install --index-url https://code.stripe.com -升级数据条
- easy_install --index-url https://code.stripe.com -升级数据条
- python setup.py安装
但是我总是收到以下错误消息:
$ sudo python stripe.py追溯(最近一次通话):< module>中的文件"stripe.py",第1行进口条纹< module>中的文件"/Users/sebastian/Desktop/stripe.py",第7行.resp = stripe.Charge.create(AttributeError:模块"对象没有属性收费"
当我尝试执行以下脚本时:
导入条stripe.api_key ='my_test_secret_key'resp = stripe.Charge.create(数量= 200,currency ='usd',卡= {'number':'4242424242424242','exp_month':10,'exp_year':2014年},description='customer@gmail.com')
解决方案
您还有另一个名为 stripe.py
的文件,因此将导入该文件,而不是 stripe 代码>库.
解决方法如下:
- 将您的
stripe.py
文件重命名为其他名称 - 删除
stripe.pyc
(如果存在)(请注意c
)
该文件位于您的桌面上:/Users/sebastian/Desktop/stripe.py
.
I have installed Stripe on my MacOSX Mavericks Macbook Pro (python 2.7) using
- pip install --index-url https://code.stripe.com --upgrade stripe
- easy_install --index-url https://code.stripe.com --upgrade stripe
- python setup.py install
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.
Here's how you fix this:
- Rename your
stripe.py
file to something different - Remove
stripe.pyc
if it exists (mind thec
)
Said file is on your desktop: /Users/sebastian/Desktop/stripe.py
.
这篇关于Python Stripe:“模块"对象没有属性“收费"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文