簡體   English   中英

Python Stripe:“模塊”對象沒有屬性“收費”

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM