activefrequency / pyavatax

Python and Django Integration for RESTful Avalara Tax System
BSD 3-Clause "New" or "Revised" License
6 stars 12 forks source link

Unable to import pyavatax #16

Open dsc03 opened 6 years ago

dsc03 commented 6 years ago

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.

jobelenus commented 6 years ago

My apologies, I have to re-build the ReadTheDocs project. The current import looks like:

from pyavatax import api as pyavatax_api
api = pyavatax_api.API(YOUR_AVALARA_ACCOUNT_NUMBER, YOUR_AVALARA_LICENSE_KEY, YOUR_AVALARA_COMPANY_CODE, live=False)

That said, we will be sun-setting our library because Avalara have released their own that they will be supporting and keeping up to date: https://github.com/avadev/AvaTax-Calc-REST-Python

Feel free to use this project if you like, but we won't be committing to supporting it very much longer. Thank you!

otherjoel commented 5 years ago

That said, we will be sun-setting our library because Avalara have released their own that they will be supporting and keeping up to date: https://github.com/avadev/AvaTax-Calc-REST-Python

I find that statement strange since, as of Nov 2018, the official Avatax API's documentation still links to this library. Furthermore the repo you link to hasn't seen any commits for four years. Has Avalara officially announced this anywhere?

edit: the repo you linked to is not actually a library; it's a bunch of code samples that use base Python libraries only.

kgrinberg commented 5 years ago

I believe the correct link is https://pypi.org/project/Avalara/

Blog post: https://developer.avalara.com/blog/2018/04/19/introducing-the-new-python-sdk/