![](/img/trans.png)
[英]Django - AttributeError: 'tuple' object has no attribute 'get' [ DRF, Stripe, Python ]
[英]Python Stripe: 'module' object has no attribute 'Charge'
我已經使用以下命令在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'
)
您有被稱為另一個文件stripe.py
,所以這個文件得到進口代替stripe
庫。
解決方法如下:
stripe.py
文件為其他名稱 stripe.pyc
如果存在)(注意c
) 該文件在您的桌面上: /Users/sebastian/Desktop/stripe.py
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.