简体   繁体   English

Python Stripe:“模块”对象没有属性“收费”

[英]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: 解决方法如下:

  • Rename your stripe.py file to something different 重命名您的stripe.py文件为其他名称
  • Remove 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.

相关问题 Django - AttributeError: &#39;tuple&#39; 对象没有属性 &#39;get&#39; [DRF, Stripe, Python] - Django - AttributeError: 'tuple' object has no attribute 'get' [ DRF, Stripe, Python ] &#39;module&#39;对象在cubehelix python中没有属性&#39;cmap&#39; - 'module' object has no attribute 'cmap' in cubehelix python python pycrypto:模块&#39;对象没有属性&#39;importKey&#39; - python pycrypto: module' object has no attribute 'importKey' AttributeError:&#39;module&#39;对象没有属性&#39;subscribe&#39;Python - AttributeError: 'module' object has no attribute 'subscribe' Python AttributeError:&#39;module&#39;对象没有属性&#39;call&#39;:Python - AttributeError:'module' object has no attribute 'call' :Python Python-&gt; AttributeError:“模块”对象没有属性“主” - Python -> AttributeError: 'module' object has no attribute 'main' python AttributeError:“模块”对象没有属性“ monthcalendar” - python AttributeError: 'module' object has no attribute 'monthcalendar' 模块&#39;对象没有属性&#39;drawMatches&#39; opencv python - module' object has no attribute 'drawMatches' opencv python python 属性错误:“模块”object 没有属性“fft” - python attributeerror: 'module' object has no attribute 'fft' Python 2.7“模块”对象没有属性“ setPenRadius” - Python 2.7 'module' object has no attribute 'setPenRadius'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM