How to import parse_address from libpostal library from a Jupyter Notebook on AWS EMR?

Viewed 22

I have postal imported in my Jupyter Notebook and I am currently trying to import the parse_address function from libpostal like so:

from postal.parser import parse_address

M goal is to use this parse_address to be able to parse through strings like so:

parse_address('The Book Club 100-106 Leonard St Shoreditch London EC2A 4RH, United Kingdom')

The issue that I'm facing is when I try to import the parse_address, I get a cannot open shared object file: No such file or directory error:

import postal
from postal.parser import parse_address

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-2-3393de6b6028> in <module>
----> 1 from postal.parser import parse_address

~/.local/lib/python3.7/site-packages/postal/parser.py in <module>
      1 """Python bindings to libpostal parse_address."""
----> 2 from postal import _parser
      3 from postal.utils.encoding import safe_decode
      4 
      5 

ImportError: libpostal.so.1: cannot open shared object file: No such file or directory

When I try to do the same in an SSH terminal, I can import parse_address by running export like so:

export LD_LIBRARY_PATH=/usr/local/lib

However, in Jupyter Notebook, even when I try to add LD_LIBRARY_PATH to the %env , I am still getting the No such file or directory.

I have verified that the libpostal.so.1 file exists by printing out the files in the /user/local/lib folder:

for i in os.listdir('./usr/local/lib'):
    print(i)

Prints:

python3.7
python2.7
libpostal.so.1.0.1
libpostal.so.1
libpostal.so
libpostal.la
libpostal.a
pkgconfig

I am not able to figure out why my jupyter notebook is not able to find the libpostal.so.1 file when my os library's listdir function is able to find it without a problem.

0 Answers
Related