Skip to content
Advertisement

Standardize the Addresses using Python Library address

I am trying to standardize the addresses by separating the address 1 and address 2 from the given address for all countries. Example: given address: 123 West Mifflin Street, Madison, WI, 53703 So, I am planning to use the “address” library I installed the address library by using pip install address in Anaconda. it was installed successfully. In Jupiter notebook, I typed the below code and tried to run it

from address import AddressParser, Address

ap = AddressParser()

address = ap.parse_address('123 West Mifflin Street, Madison, WI, 53703')

I am getting the below error:

File "C:Usersvattianaconda3libsite-packagesIPythoncoreinteractiveshell.py", line 3418, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)

  File "<ipython-input-26-c32728fd4cb5>", line 1, in <module>
    from address import AddressParser, Address

  File "C:Usersvattianaconda3libsite-packagesaddress__init__.py", line 1, in <module>
    from .address import Address, AddressParser

  File "C:Usersvattianaconda3libsite-packagesaddressaddress.py", line 185
    print "Unmatched token: ", token
          ^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print("Unmatched token: ", token)?

Can someone please help me resolve this issue?

Advertisement

Answer

Your problem is that you are running Python 2.X code with a Python 3.x interpreter. The line at the bottom of the error stacktrace you provide is:

print "Unmatched token: ", token

This code is valid in Python 2.X, but is a syntax error in Python 3.X. Since it appears that the code in question is in the module address rather than your code, you need to either drop down to Python 2.X yourself, or upgrade that module to a version that supports python 3.X. Since pip usually installs the latest version of a package, my guess is that the author of that package hasn’t upgraded it to support Python 3.X. It’s possible that there’s Python 3.X version under a different name.

UPDATE: I was curious if this problem was isolated to Anaconda. I use the standard vanilla Python distribution. I just tried installing the package and running your code. I get the same thing.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement