selva221724 / pypostalwin

libpostal wrapper python package for windows
MIT License
13 stars 5 forks source link

Index Error when running sample code #2

Closed devl7b closed 2 years ago

devl7b commented 2 years ago

Hi there,

When I attempt to ruin the sample code in your install directions, I get the following error:

IndexError Traceback (most recent call last)

in 1 parser = pypostalwin.AddressParser() ----> 2 parsedAddress = parser.runParser("The White House 1600 Pennsylvania Avenue NW, Washington, DC 20500, USA") 3 print(parsedAddress) ~\Anaconda3\lib\site-packages\pypostalwin.py in runParser(self, address) 56 break 57 result += line ---> 58 return outputStripper(result) 59 60 def terminateParser(self): ~\Anaconda3\lib\site-packages\pypostalwin.py in outputStripper(result) 18 19 def outputStripper(result): ---> 20 result = result.split('Result:\n\n')[1].split('\n\n> ')[0].replace('\n', '') 21 result = stringToJSON(result) 22 return result IndexError: list index out of range
devl7b commented 2 years ago

Alright, I got further along and resolved my issues with the split. I thought PIPE and popen were included in python by default, but it turned out I needed to install them.

After I did, I got a new error message which I believe has something to do with passing the address to the Windows C runtime, but I'm not too sure.


OSError Traceback (most recent call last)

in ----> 1 parsedAddress = parser.runParser("123 Main St., Denver, CO, 80228") ~\Anaconda3\lib\site-packages\pypostalwin.py in runParser(self, address) 48 address = address + '\n' 49 self.process.stdin.write(address) ---> 50 self.process.stdin.flush() 51 52 result = '' OSError: [Errno 22] Invalid argument
selva221724 commented 2 years ago

Hi @devl7b , let me look at your issue quicky

selva221724 commented 2 years ago

Hi @devl7b ,

I am getting the output as

[{'house_number': '123'}, {'road': 'main st.'}, {'city': 'denver'}, {'state': 'co'}, {'postcode': '80228'}]

Looks like it is some other dependency issue, what is your python version, can you do pip freeze and paste it here

Also, did you follow the exact procedure here

devl7b commented 2 years ago

Hi @selva221724 ,

I am on python 3.8.8, I've unzipped the package into the following location: "C:\Workbench\libpostal"

As far as MSYS2 is concered, I have it downloaded but haven't done anything else with it.

I am also running this in a jupyter notebook, I can try putting it into a script and see if that's part of the issue.

Thank you for trying to support libpostal's library on windows, it's a great tool but the windows support is lacking. I was excited to see someone else take a crack at it.

selva221724 commented 2 years ago

Hi @devl7b , can you navigate to this path C:\Workbench\libpostal\src\address_parser.exe and open the .exe file and Please let me know if that is opening and check if you can put some address and get the result on that terminal.