Skip to content

Unable to import pyavatax #16

@dsc03

Description

@dsc03

Hi there,

Hope you're well. I'm trying to use pyavatax. I install it using pip install pyavatax. I'm using Python 2.7 and I've upgraded to the most recent version of pyavatax available. I'm trying to execute a script and I'm continuously getting the following issue: AttributeError: 'module' object has no attribute 'API'

I'm not sure what the issue is, and I've tried uninstalling and reinstalling multiple times. There is nothing strange about my code, as I literally copy pasted the docs and added my own company specific info:

import pyavatax
  def test_avalara():
    api = pyavatax.API(YOUR_AVALARA_ACCOUNT_NUMBER, YOUR_AVALARA_LICENSE_KEY, YOUR_AVALARA_COMPANY_CODE, live=False)
    data = {
        "DocDate": "2012-06-13",
        "CompanyCode": YOUR_AVALARA_COMPANY_CODE,
        "CustomerCode": "YourClientsCustomerCode",
        "DocCode": "20120613-1",
        "DocType": "SalesOrder",
        "Addresses":
        [
            {
                "AddressCode": "1",
                "Line1": "435 Ericksen Avenue Northeast",
                "Line2": "#250",
                "City": "Bainbridge Island",
                "Region": "WA",
                "PostalCode": "98110",
                "Country": "US",
            },
            {
                "AddressCode": "2",
                "Line1": "7562 Kearney St.",
                "City": "Commerce City",
                "Region": "CO",
                "PostalCode": "80022-1336",
                "Country": "US",
            },
        ],
        "Lines":
        [
            {
                "LineNo": "1",
                "DestinationCode": "2",
                "OriginCode": "1",
                "ItemCode": "AvaDocs",
                "Description": "Box of Avalara Documentation",
                "Qty": 1,
                "Amount": "100",
            },
        ],
    }
    try:
        tax = api.post_tax(data)
    except pyavatax.AvalaraServerNotReachableException:
        raise Exception('Avalara is currently down')
    else:  # try else runs whenever there is no exception
        if tax.is_success is True:
            tax.total_tax  # has your total amount of tax for this transaction
        else:
            raise Exception(tax.error)  # Avalara found a problem with your data


if __name__ == '__main__':
    test_avalara()

Do you have any idea why this is happening? Would be immensely appreciated, thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions