繁体   English   中英

Shippo - Python 包异步问题

[英]Shippo - Python Package Async Issue

我已经导入了 Shippo python 包,我正在尝试让他们的示例工作,但我遇到了以下错误消息(见下文)。 我在最新的 API 版本上运行 Python 3.7.2。

这是错误 -

    Traceback (most recent call last):
      File "c:/Users/tom/Documents/PyProjects/goShippo/goShippoCreateLabels.py", line 1, in <module>
        import shippo
      File "C:\Python\lib\site-packages\shippo\__init__.py", line 8, in <module>
        from shippo.resource import (
      File "C:\Python\lib\site-packages\shippo\resource.py", line 303
        def get_rates(cls, object_id, async=False, api_key=None, currency=None, **params):
                                      ^
SyntaxError: invalid syntax

这是代码 -

import shippo

shippo.api_key = "shippo_test_123456789"

address_from = {
    "name": "Shawn Ippotle",
    "company": "Shippo",
    "street1": "215 Clayton St.",
    "city": "San Francisco",
    "state": "CA",
    "zip": "94117",
    "country": "US",
    "phone": "+1 555 341 9393",
    "email": "shippotle@goshippo.com"
}

address_to = {
    "name": "Mr Hippo",
    "company": "",
    "street1": "Broadway 1",
    "street2": "",
    "city": "New York",
    "state": "NY",
    "zip": "10007",
    "country": "US",
    "phone": "+1 555 341 9393",
    "email": "mrhippo@goshippo.com",
    "metadata": "Hippos dont lie"
}

parcel = {
    "length": "5",
    "width": "5",
    "height": "5",
    "distance_unit": "in",
    "weight": "2",
    "mass_unit": "lb"
}

shipment = {
    "address_from": address_from,
    "address_to": address_to,
    "parcels": [parcel]
}

transaction = shippo.Transaction.create(
    shipment = shipment,
    carrier_account = "b741b99f95e841639b54272834bc478c",
    servicelevel_token = "usps_priority"
)

这个包的 Python 版本覆盖率高达 3.3。 在 3.6+ 版本中,“async”成为保留关键字,导致您遇到语法错误。

由于“async”是默认参数,因此最好的解决方法是将“async”参数显式更改为“asynchronous”。 这至少应该避免语法错误,直到包更新为 3.6+ 支持。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM