Python AttributeError:“模块”对象没有属性“postDirectOrder”

Python AttributeError:“模块”对象没有属性“postDirectOrder”,python,Python,我试图在我的一个项目中使用这个python包 但我注意到,出于某种奇怪的原因,作者把所有的逻辑都塞进了书中,这对我来说毫无意义,但是 因此,当我尝试使用该软件包时,会出现以下错误: 'module' object has no attribute 'postDirectOrder 我使用的是Python 2.7.7,我从pesapal import*尝试过,但没有成功。我试过: >>> from pesapal import PesaPal >>> url

我试图在我的一个项目中使用这个python包

但我注意到,出于某种奇怪的原因,作者把所有的逻辑都塞进了书中,这对我来说毫无意义,但是

因此,当我尝试使用该软件包时,会出现以下错误:

'module' object has no attribute 'postDirectOrder
我使用的是Python 2.7.7,我从pesapal import*尝试过,但没有成功。我试过:

>>> from pesapal import PesaPal
>>> url = PesaPal.postDirectOrder(post_params, request_data)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: unbound method postDirectOrder() must be called with PesaPal instance as first argument (got dict inst
ance instead)

0.3版本与以后的代码有很大不同;它包含一个类PesaPal,该类接受consumer_key和consumer_secret参数:

pp = PesaPal(key, secret)
url = pp.postDirectOrder(post_params, request_data)
该项目从未正确标记过0.3版本,但存在一个错误;你可以试着了解一下你的期望

其中的项目自述包括一个示例:


如果您直接从github安装代码,那么示例将按照当前自述文件中的指示工作。如果你使用pip,你必须使用上面的例子,非常困惑的家伙我想..@jwesonga:我猜这个项目从来没有在PyPI上发布过0.4和0.5;他们对结构进行了重大重构。我猜它仍处于alpha发布周期,允许维护人员在如何构造包方面有很大的自由。
import pesapal, urllib2

consumer_key ='consumer_key'
consumer_secret = 'consumer_secret'
testing = False

### make client
client = pesapal.PesaPal(consumer_key, consumer_secret, testing)

### post a direct order

request_data = {
  'Amount': '',
  'Description': '',
  'Type': '',
  'Reference': '',
  'PhoneNumber': ''
}
post_params = {
  'oauth_callback': 'www.example.com/post_payment_page'
}
request = client.postDirectOrder(post_params, request_data)
# get url to display as an iframe
print request.to_url()