libpostal
libpostal copied to clipboard
Successfully installed libpostal on ubuntu But still unable to import
Hello @albarrentine and @Phil Hutchinson
I have followed the steps and was able to execute successfully on Ubuntu 20.04 LTS but still unable to import address_parser
saikiran@saikiran-virtual-machine:~$ pkg-config --cflags libpostal
-I/usr/local/include
saikiran@saikiran-virtual-machine:~$ pkg-config --libs libpostal
-L/usr/local/lib -lpostal
saikiran@saikiran-virtual-machine:~$ pkg-config --cflags --libs libpostal
-I/usr/local/include -L/usr/local/lib -lpostal
saikiran@saikiran-virtual-machine:~$ python3
Python 3.8.2 (default, Apr 27 2020, 15:53:34)
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
import postal from postal.parser import parse_address ERR Could not find parser model file of known type at address_parser_load (address_parser.c:215) errno: No such file or directory ERR Error loading address parser module, dir=(null) at libpostal_setup_parser_datadir (libpostal.c:434) errno: No such file or directory Traceback (most recent call last): File "
", line 1, in File "/home/saikiran/.local/lib/python3.8/site-packages/postal/parser.py", line 2, in from postal import _parser SystemError: initialization of _parser raised unreported exception
I use libpostal with python binding. A good way to use libpostal python binding is to install this library pylibpostal 1.0.0 instead.
When I used pylibpostal 1.0.0 in my environment(Centos 7, Jupyter notebook), I met this issue. The reason is that my jupyter notebook cannot read the environment variable LIBPOSTAL_DATA_DIR that path storing the data files of libpostal. Hence, I explicitly set the environment variable LIBPOSTAL_DATA_DIR in my code before importing the pylibpostal os.environ['LIBPOSTAL_DATA_DIR']='your absolute path to store data files of libpostal'