Python bindings to libpostal for fast international address parsing/normalization

Overview

pypostal

Build Status PyPI version License

These are the official Python bindings to https://github.com/openvenues/libpostal, a fast statistical parser/normalizer for street addresses anywhere in the world.

Usage

from postal.expand import expand_address
expand_address('Quatre vingt douze Ave des Champs-Élysées')

from postal.parser import parse_address
parse_address('The Book Club 100-106 Leonard St, Shoreditch, London, Greater London, EC2A 4RH, United Kingdom')

Installation

Before using the Python bindings, you must install the libpostal C library. Make sure you have the following prerequisites:

On Ubuntu/Debian

sudo apt-get install curl autoconf automake libtool python-dev pkg-config

On CentOS/RHEL

sudo yum install curl autoconf automake libtool python-devel pkgconfig

On Mac OSX

brew install curl autoconf automake libtool pkg-config

Installing libpostal

git clone https://github.com/openvenues/libpostal
cd libpostal
./bootstrap.sh
./configure --datadir=[...some dir with a few GB of space...]
make
sudo make install

# On Linux it's probably a good idea to run
sudo ldconfig

To install the Python library, just run:

pip install postal

Compatibility

pypostal supports Python 2.7+ and Python 3.4+. These bindings are written using the Python C API and thus support CPython only. Since libpostal is a standalone C library, support for PyPy is still possible with a CFFI wrapper, but is not a goal for this repo.

Tests

Make sure you have nose installed, then run:

python setup.py build_ext --inplace
nosetests postal/tests

The build_ext --inplace business is needed so the C extensions build in the source checkout directory and are accessible/importalbe by the Python modules.

Comments
  • Installation/Usage unclear

    Installation/Usage unclear

    Hi there. Running in terminal on a CentOS7 box. I installed libpostal and can use its utilities, and followed instructions to install python bindings (sudo pip install postal), but I get this error when trying to use code examples:

    from postal.expand import expand_address ... cannot open shared object file: No such file or directory...

    dir(postal) = ['builtins', 'doc', 'file', 'name', 'package', 'path']

    opened by easherma 17
  • fatal error: 'libpostal/libpostal.h' file not found

    fatal error: 'libpostal/libpostal.h' file not found

    I followed the instructions and installed libpostal.

    git clone https://github.com/openvenues/libpostal
    cd libpostal
    ./bootstrap.sh
    mkdir ~/libpostal-datadir
    ./configure --datadir=~/libpostal-datadir
    make
    

    I ran into issues with language_classifier failing, but downloaded it manually with curl:

    curl http://libpostal.s3.amazonaws.com/language_classifier.tar.gz -o ~/libpostal-datadir/libpostal/language_classifier.tar.gz
    cd ~/libpostal-datadir/libpostal
    tar -xzf language_classifier.tar.gz
    

    I'm able to use the library:

    ➜  libpostal git:(master) ✗ src/address_parser
    Loading models...
    
    Welcome to libpostal's address parser.
    
    Type in any address to parse and print the result.
    
    Special commands:
    
    .language [code] to specify a language
    .country [code] to specify a country
    .exit to quit the program
    
    > 123 Main Street
    
    Result:
    
    {
      "house_number": "123",
      "road": "main street"
    }
    
    > 
    

    But can't install the pypostal package:

    (country-append) ➜  pypostal git:(master) pip install postal
    Collecting postal
      Using cached postal-0.3.tar.gz
    Requirement already satisfied: six in /Users/nicole/.virtualenvs/country-append/lib/python2.7/site-packages (from postal)
    Building wheels for collected packages: postal
      Running setup.py bdist_wheel for postal ... error
      Complete output from command /Users/nicole/.virtualenvs/country-append/bin/python -u -c "import setuptools, tokenize;__file__='/private/var/folders/8f/_lk_kbrj49q3b317sp3b9y1c0000gn/T/pip-build-AbquqQ/postal/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /var/folders/8f/_lk_kbrj49q3b317sp3b9y1c0000gn/T/tmpF3t5tapip-wheel- --python-tag cp27:
      running bdist_wheel
      running build
      running build_py
      creating build
      creating build/lib.macosx-10.12-intel-2.7
      creating build/lib.macosx-10.12-intel-2.7/postal
      copying postal/__init__.py -> build/lib.macosx-10.12-intel-2.7/postal
      copying postal/expand.py -> build/lib.macosx-10.12-intel-2.7/postal
      copying postal/parser.py -> build/lib.macosx-10.12-intel-2.7/postal
      creating build/lib.macosx-10.12-intel-2.7/postal/tests
      copying postal/tests/__init__.py -> build/lib.macosx-10.12-intel-2.7/postal/tests
      copying postal/tests/test_expand.py -> build/lib.macosx-10.12-intel-2.7/postal/tests
      copying postal/tests/test_parser.py -> build/lib.macosx-10.12-intel-2.7/postal/tests
      creating build/lib.macosx-10.12-intel-2.7/postal/utils
      copying postal/utils/__init__.py -> build/lib.macosx-10.12-intel-2.7/postal/utils
      copying postal/utils/encoding.py -> build/lib.macosx-10.12-intel-2.7/postal/utils
      copying postal/utils/enum.py -> build/lib.macosx-10.12-intel-2.7/postal/utils
      copying postal/utils/omitted.py -> build/lib.macosx-10.12-intel-2.7/postal/utils
      running build_ext
      building 'postal._expand' extension
      creating build/temp.macosx-10.12-intel-2.7
      creating build/temp.macosx-10.12-intel-2.7/postal
      cc -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -Qunused-arguments -Qunused-arguments -arch i386 -arch x86_64 -pipe -I/usr/local/include -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c postal/pyexpand.c -o build/temp.macosx-10.12-intel-2.7/postal/pyexpand.o -std=c99 -Wno-unused-function
      postal/pyexpand.c:2:10: fatal error: 'libpostal/libpostal.h' file not found
      #include <libpostal/libpostal.h>
               ^
      1 error generated.
      error: command 'cc' failed with exit status 1
      
      ----------------------------------------
      Failed building wheel for postal
      Running setup.py clean for postal
    Failed to build postal
    Installing collected packages: postal
      Running setup.py install for postal ... error
        Complete output from command /Users/nicole/.virtualenvs/country-append/bin/python -u -c "import setuptools, tokenize;__file__='/private/var/folders/8f/_lk_kbrj49q3b317sp3b9y1c0000gn/T/pip-build-AbquqQ/postal/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /var/folders/8f/_lk_kbrj49q3b317sp3b9y1c0000gn/T/pip-E3CTvr-record/install-record.txt --single-version-externally-managed --compile --install-headers /Users/nicole/.virtualenvs/country-append/include/site/python2.7/postal:
        running install
        running build
        running build_py
        creating build
        creating build/lib.macosx-10.12-intel-2.7
        creating build/lib.macosx-10.12-intel-2.7/postal
        copying postal/__init__.py -> build/lib.macosx-10.12-intel-2.7/postal
        copying postal/expand.py -> build/lib.macosx-10.12-intel-2.7/postal
        copying postal/parser.py -> build/lib.macosx-10.12-intel-2.7/postal
        creating build/lib.macosx-10.12-intel-2.7/postal/tests
        copying postal/tests/__init__.py -> build/lib.macosx-10.12-intel-2.7/postal/tests
        copying postal/tests/test_expand.py -> build/lib.macosx-10.12-intel-2.7/postal/tests
        copying postal/tests/test_parser.py -> build/lib.macosx-10.12-intel-2.7/postal/tests
        creating build/lib.macosx-10.12-intel-2.7/postal/utils
        copying postal/utils/__init__.py -> build/lib.macosx-10.12-intel-2.7/postal/utils
        copying postal/utils/encoding.py -> build/lib.macosx-10.12-intel-2.7/postal/utils
        copying postal/utils/enum.py -> build/lib.macosx-10.12-intel-2.7/postal/utils
        copying postal/utils/omitted.py -> build/lib.macosx-10.12-intel-2.7/postal/utils
        running build_ext
        building 'postal._expand' extension
        creating build/temp.macosx-10.12-intel-2.7
        creating build/temp.macosx-10.12-intel-2.7/postal
        cc -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -Qunused-arguments -Qunused-arguments -arch i386 -arch x86_64 -pipe -I/usr/local/include -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c postal/pyexpand.c -o build/temp.macosx-10.12-intel-2.7/postal/pyexpand.o -std=c99 -Wno-unused-function
        postal/pyexpand.c:2:10: fatal error: 'libpostal/libpostal.h' file not found
        #include <libpostal/libpostal.h>
                 ^
        1 error generated.
        error: command 'cc' failed with exit status 1
        
        ----------------------------------------
    Command "/Users/nicole/.virtualenvs/country-append/bin/python -u -c "import setuptools, tokenize;__file__='/private/var/folders/8f/_lk_kbrj49q3b317sp3b9y1c0000gn/T/pip-build-AbquqQ/postal/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /var/folders/8f/_lk_kbrj49q3b317sp3b9y1c0000gn/T/pip-E3CTvr-record/install-record.txt --single-version-externally-managed --compile --install-headers /Users/nicole/.virtualenvs/country-append/include/site/python2.7/postal" failed with error code 1 in /private/var/folders/8f/_lk_kbrj49q3b317sp3b9y1c0000gn/T/pip-build-AbquqQ/postal/
    

    I added the location of libpostal.pc to PKG_CONFIG_PATH:

    (country-append) ➜  pypostal git:(master) echo $PKG_CONFIG_PATH 
    /Users/nicole/GitHub/libpostal
    

    However it still fails with the same error. I've also tried cloning this repository and installing with python setup.py install but get the same error. Any help is appreciated!

    opened by nicolewhite 10
  • Setup problem

    Setup problem

    Hi there: I hit a snag when trying to follow the setup instructions. At the "python setup.py install" step, I got an error message that indicates the compiler can't find libpostal/libpostal.h.

    libpostal itself seems to be correctly installed and I'm able to run it from the command line.

    I'm running the OSX system version of Python 2.7.10. Before I go mucking with new Python installations or moving directories around, thought I'd post this here. Since no one else has reported this issue, it's probably something stupid on my end...

    Here's what I see when I try to run setup.py. It's the same error regardless of whether I preface with sudo:

    rob$ python setup.py install
    running install
    Checking .pth file support in /Library/Python/2.7/site-packages/
    /usr/bin/python -E -c pass
    TEST PASSED: /Library/Python/2.7/site-packages/ appears to support .pth files
    running bdist_egg
    running egg_info
    writing requirements to pypostal.egg-info/requires.txt
    writing pypostal.egg-info/PKG-INFO
    writing top-level names to pypostal.egg-info/top_level.txt
    writing dependency_links to pypostal.egg-info/dependency_links.txt
    reading manifest file 'pypostal.egg-info/SOURCES.txt'
    writing manifest file 'pypostal.egg-info/SOURCES.txt'
    installing library code to build/bdist.macosx-10.11-intel/egg
    running install_lib
    running build_py
    running build_ext
    building 'postal._expand' extension
    cc -fno-strict-aliasing -fno-common -dynamic -arch x86_64 -arch i386 -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch x86_64 -arch i386 -pipe -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c postal/pyexpand.c -o build/temp.macosx-10.11-intel-2.7/postal/pyexpand.o -std=c99 -Wno-unused-function
    postal/pyexpand.c:2:10: fatal error: 'libpostal/libpostal.h' file not found
    #include <libpostal/libpostal.h>
             ^
    1 error generated.
    error: command 'cc' failed with exit status 1
    
    opened by robbarry 10
  • Cannot Allocate memory error

    Cannot Allocate memory error

    While parsing address by giving a string it shows Cannot Allocate memory error My Machine Details - RAM 4GB, High End Processor. Help me to get this solved.

    opened by ibu2710 6
  • Enable pip-only installation of pypostal (i.e. no user-provided C dependencies) by offering self-contained binary wheels

    Enable pip-only installation of pypostal (i.e. no user-provided C dependencies) by offering self-contained binary wheels

    Judging from my experience, as well as from the open issues against this repo, the top issue facing newcomers to pypostal is simply installing it.

    This PR aims to offer a pure Python installation experience on Linux by building manylinux wheels that bundle the required C libararies. Someone should be able to pip install postal without doing anything else (like building libpostal) and it should just work.

    The scripts added here build Python wheels that include the libpostal binaries. It does so by following the template laid out in the PyPA's manylinux demo, except I wrote this against GitHub Actions instead of Travis CI. Travis CI has very low limits on compute usage for public projects, which get exhausted very quickly when building libpostal.

    There are several TODOs to complete this work:

    • [ ] Figure out a solution for the ~2 GB of model data. Do we a) bundle it in the wheels, b) enable pypostal to dynamically download it, or c) have users download it themselves and simply instruct them to set LIBPOSTAL_DATA_DIR?
    • [ ] Cache the Docker image generated when building libpostal on GitHub so that we only incur that cost when bumping the version of libpostal we're targeting. (Note that this Docker image is only used to generate the wheels. The wheels themselves having nothing to do with Docker.)
    • [ ] Update the release process to include these newly built wheels.

    You can see GitHub Actions successfully running pypostal from these new wheels here, with the model data already provided.

    The test step in GitHub Actions, which tries to mimic the workflow of a new user installing pypostal, currently fails because it cannot find the model data. (This is what the TODO I described just above is about.)

    Before continuing this work, I'd like to see if the maintainers are interested in the direction this is going in, and if they have some time to offer to shepherd this through to completion. I am also happy to just hand this off to someone else. The pypostal project seems to be in maintenance mode, so I wonder if there is enough energy to make a major packaging change like this.

    opened by nchammas 5
  • nose tests failing

    nose tests failing

    Trying to run the initial tests documented using >> nosetests postal/tests ERROR: Failure: ImportError (cannot import name '_expand') ERROR: Failure: ImportError (cannot import name '_parser') Any help ?

    opened by jvidin 5
  • near_dupe_hashes returns empty array

    near_dupe_hashes returns empty array

    Not sure what's going on, postal.near_dupe.near_dupe_hashes simply returns an empty list no matter what the inputs are. I'm passing in the labels and values created from the parse_address function

    opened by mhmdmodan 4
  • pip installer looks for README.rst, whereas it's README.md

    pip installer looks for README.rst, whereas it's README.md

    Trying to install in Anaconda Python 3.6 on Ubuntu 16.10:

    pip install pypostal Collecting pypostal Downloading pyPostal-1.1.tar.gz Complete output from command python setup.py egg_info: Traceback (most recent call last): File "", line 1, in File "/tmp/pip-build-it1zbgs0/pypostal/setup.py", line 10, in long_description=codecs.open('README.rst', "r", "utf-8").read(), File "/home/david/anaconda3/envs/py36/lib/python3.6/codecs.py", line 895, in open file = builtins.open(filename, mode, buffering) FileNotFoundError: [Errno 2] No such file or directory: 'README.rst'

    ----------------------------------------
    

    Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-it1zbgs0/pypostal/

    opened by Prooffreader 4
  • postal.parser.parse_address() returns a list instead of a dict

    postal.parser.parse_address() returns a list instead of a dict

    Just began using libpostal and decided to try its python binding.

    Whats I immediately noticed is that comparing to the command-line 'src/address_parser' the corresponding python function return a list. Compare:

    src/address_parser:

    1010 EASY ST OTTAWA K1A 0B1

    Result:

    { "house_number": "1010", "road": "easy st", "city": "ottawa", "postcode": "k1a 0b1" }

    python postal:

    parse('1010 EASY ST OTTAWA K1A 0B1') [(u'1010', u'house_number'), (u'easy st', u'road'), (u'ottawa', u'city'), (u'k1a 0b1', u'postcode')]

    I could not find a way to output the data in a more organized, JSON way. What's the reason it's done like that? Is it always guaranteed to have a value as a first element, and a key as a second?

    Please advise.

    opened by antimirov 4
  • pip installation with Python 3.10

    pip installation with Python 3.10

    Installation of pypostal into Python 3.10 virtual environment fails due to FileNotFoundError: [Errno 2] No such file or directory: 'README.rst':

    (venv) ➜  FFDMS-Data-Management-System git:(master) ✗ pip install pypostal
    Collecting pypostal
      Using cached pyPostal-1.1.tar.gz (6.7 kB)
        ERROR: Command errored out with exit status 1:
         command: /Users/XXXXX/code/FFDMS-Data-Management-System/venv/bin/python3 -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/_g/35jgpkvn39z4fhwdykwybl4n9wcp5y/T/pip-install-foawjnb8/pypostal_c21a686d102e488aaf61b4e1bd41d659/setup.py'"'"'; __file__='"'"'/private/var/folders/_g/35jgpkvn39z4fhwdykwybl4n9wcp5y/T/pip-install-foawjnb8/pypostal_c21a686d102e488aaf61b4e1bd41d659/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /private/var/folders/_g/35jgpkvn39z4fhwdykwybl4n9wcp5y/T/pip-pip-egg-info-eup66d5h
             cwd: /private/var/folders/_g/35jgpkvn39z4fhwdykwybl4n9wcp5y/T/pip-install-foawjnb8/pypostal_c21a686d102e488aaf61b4e1bd41d659/
        Complete output (7 lines):
        Traceback (most recent call last):
          File "<string>", line 1, in <module>
          File "/private/var/folders/_g/35jgpkvn39z4fhwdykwybl4n9wcp5y/T/pip-install-foawjnb8/pypostal_c21a686d102e488aaf61b4e1bd41d659/setup.py", line 10, in <module>
            long_description=codecs.open('README.rst', "r", "utf-8").read(),
          File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/codecs.py", line 905, in open
            file = builtins.open(filename, mode, buffering)
        FileNotFoundError: [Errno 2] No such file or directory: 'README.rst'
        ----------------------------------------
    WARNING: Discarding https://files.pythonhosted.org/packages/e7/96/145d60501264de505926f48f52c29c5fd20d066f2e158107a66ea963cf56/pyPostal-1.1.tar.gz#sha256=961849750395ab72306b961c586ac04764f6d781bc205632a327cb7359a2f3c7 (from https://pypi.org/simple/pypostal/). Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
      Using cached pyPostal-1.0.tar.gz (5.6 kB)
        ERROR: Command errored out with exit status 1:
         command: /Users/XXXXX/code/FFDMS-Data-Management-System/venv/bin/python3 -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/_g/35jgpkvn39z4fhwdykwybl4n9wcp5y/T/pip-install-foawjnb8/pypostal_e37aedc2bd474ee8b152c05998fb3333/setup.py'"'"'; __file__='"'"'/private/var/folders/_g/35jgpkvn39z4fhwdykwybl4n9wcp5y/T/pip-install-foawjnb8/pypostal_e37aedc2bd474ee8b152c05998fb3333/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /private/var/folders/_g/35jgpkvn39z4fhwdykwybl4n9wcp5y/T/pip-pip-egg-info-21c2dj4z
             cwd: /private/var/folders/_g/35jgpkvn39z4fhwdykwybl4n9wcp5y/T/pip-install-foawjnb8/pypostal_e37aedc2bd474ee8b152c05998fb3333/
        Complete output (7 lines):
        Traceback (most recent call last):
          File "<string>", line 1, in <module>
          File "/private/var/folders/_g/35jgpkvn39z4fhwdykwybl4n9wcp5y/T/pip-install-foawjnb8/pypostal_e37aedc2bd474ee8b152c05998fb3333/setup.py", line 10, in <module>
            long_description=codecs.open('README.rst', "r", "utf-8").read(),
          File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/codecs.py", line 905, in open
            file = builtins.open(filename, mode, buffering)
        FileNotFoundError: [Errno 2] No such file or directory: 'README.rst'
        ----------------------------------------
    WARNING: Discarding https://files.pythonhosted.org/packages/b1/c4/7b1c797924d7835aad10a83842b47494b694af4bbde0068e679be7ce9e87/pyPostal-1.0.tar.gz#sha256=f4ff5d59e5e236f45171b80baf7e5b6183e51ed6e9dc249ebe93db678713ee37 (from https://pypi.org/simple/pypostal/). Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
    ERROR: Could not find a version that satisfies the requirement pypostal (from versions: 1.0p1, 1.0p2, 1.0p3, 1.1d, 1.0, 1.1b0, 1.1rc0, 1.1)
    ERROR: No matching distribution found for pypostal
    
    opened by fkromer 3
  • Enable datadir ENV variable

    Enable datadir ENV variable

    Summary

    Add an option to change the datadir location in python. Our use case is for running in PySpark, similar to issue openvenues/libpostal#153.

    resolves #58

    opened by uzadude 3
  • It seems there is a memory leak in pyexpand.c

    It seems there is a memory leak in pyexpand.c

    Using valgrind to test the python api expand_address, I got a report:

    ==231== 51,166 bytes in 1,945 blocks are definitely lost in loss record 149 of 150
    ==231==    at 0x4C29F73: malloc (vg_replace_malloc.c:309)
    ==231==    by 0x59EBB89: strdup (in /usr/lib64/libc-2.17.so)
    ==231==    by 0x87EBD72: PyObject_to_string (pyutils.c:59)
    ==231==    by 0x87EB7CF: py_expand (pyexpand.c:120)
    ==231==    by 0x2D2077: cfunction_call_varargs (call.c:755)
    ==231==    by 0x2D2077: PyCFunction_Call (call.c:786)
    ==231==    by 0x2D2077: do_call_core (ceval.c:4641)
    ==231==    by 0x2D2077: _PyEval_EvalFrameDefault (ceval.c:3191)
    ==231==    by 0x220E84: PyEval_EvalFrameEx (ceval.c:547)
    ==231==    by 0x220E84: _PyEval_EvalCodeWithName (ceval.c:3930)
    ==231==    by 0x240CD2: _PyFunction_FastCallKeywords (call.c:433)
    ==231==    by 0x2CB394: call_function (ceval.c:4616)
    ==231==    by 0x2CB394: _PyEval_EvalFrameDefault (ceval.c:3124)
    ==231==    by 0x220E84: PyEval_EvalFrameEx (ceval.c:547)
    ==231==    by 0x220E84: _PyEval_EvalCodeWithName (ceval.c:3930)
    ==231==    by 0x222272: PyEval_EvalCodeEx (ceval.c:3959)
    ==231==    by 0x222272: PyEval_EvalCode (ceval.c:524)
    ==231==    by 0x32FC81: run_mod (pythonrun.c:1037)
    ==231==    by 0x339E1D: PyRun_FileExFlags (pythonrun.c:990)
    

    Checking the source of function py_expand in pyexpand.c, line 120, it seems memory owning by the variable input is not freed

    opened by onriv 0
  • ModuleNotFoundError: No module named 'postal'

    ModuleNotFoundError: No module named 'postal'

    Hi,

    I'm trying to set this up to be callable through an apache server on an ubuntu box. I followed the instructions and got everything installed. It seems to work fine when calling the script from Terminal. However, I get the following error in the apache logs when I make a call to apache to execute the script. I believe it might be some pathing issue. Any ideas will be appreciated.

    File "/var/www/html/cgi-bin/get_parsedAddress.py", line 5, in from postal.parser import parse_address ModuleNotFoundError: No module named 'postal'

    opened by bryan-yen 0
  • Error building on Windows

    Error building on Windows

    Hi All,

    I am trying to build pypostal on Windows and have successfully built the postal.lib but when I attempt to "pip install postal" I get this error. Any ideas on how to fix this please?

      "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29333\bin\HostX86\x64\cl.exe" /c /nologo /O2 /W3 /GL /DNDEBUG /MD -I/usr/local/include -IC:\dev\libpostal\headers\include "-IC:\Users\My ser\miniconda3\envs\myenv\include" "-IC:\Users\My ser\miniconda3\envs\myenv\Include" "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29333\ATLMFC\include" "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29333\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\cppwinrt" "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29333\ATLMFC\include" "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29333\include" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\include\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\cppwinrt" /Tcpostal/pyexpand.c /Fobuild\temp.win-amd64-cpython-39\Release\postal/pyexpand.obj -std=c99
      cl : Command line warning D9002 : ignoring unknown option '-std=c99'
      pyexpand.c
      C:\dev\libpostal\headers\include\stdio.h(577): error C2059: syntax error: 'type'
      C:\dev\libpostal\headers\include\stdio.h(584): error C2059: syntax error: 'type'
      C:\dev\libpostal\headers\include\stdio.h(590): error C2059: syntax error: 'type'
      C:\dev\libpostal\headers\include\stdio.h(851): error C2059: syntax error: 'type'
      C:\dev\libpostal\headers\include\stdio.h(881): error C2059: syntax error: 'type'
      C:\dev\libpostal\headers\include\stdio.h(1235): error C2059: syntax error: 'type'
      C:\dev\libpostal\headers\include\stdio.h(1242): error C2059: syntax error: 'type'
      C:\dev\libpostal\headers\include\stdio.h(1248): error C2059: syntax error: 'type'
      C:\dev\libpostal\headers\include\stdio.h(1364): error C2059: syntax error: 'type'
      C:\dev\libpostal\headers\include\stdio.h(1374): error C2059: syntax error: 'type'
      C:\dev\libpostal\headers\include\swprintf.inl(27): error C2059: syntax error: 'type'
      C:\dev\libpostal\headers\include\swprintf.inl(34): error C2059: syntax error: 'type'
      C:\dev\libpostal\headers\include\stdlib.h(389): error C2085: '_exit': not in formal parameter list
      C:\dev\libpostal\headers\include\stdlib.h(389): error C2143: syntax error: missing ';' before 'type'
      C:\dev\libpostal\headers\include\stdlib.h(396): error C2085: '_Exit': not in formal parameter list
      C:\dev\libpostal\headers\include\stdlib.h(396): error C2143: syntax error: missing ';' before 'type'
      C:\dev\libpostal\headers\include\stdlib.h(399): error C2085: '_Exit': not in formal parameter list
      C:\dev\libpostal\headers\include\stdlib.h(399): error C2143: syntax error: missing ';' before '{'
      C:\dev\libpostal\headers\include\stdlib.h(399): warning C4013: '_exit' undefined; assuming extern returning int
      C:\dev\libpostal\headers\include\stdlib.h(399): error C2065: 'status': undeclared identifier
      C:\dev\libpostal\headers\include\stdlib.h(405): error C2059: syntax error: 'type'
      C:\dev\libpostal\headers\include\stdlib.h(683): error C2491: '_beep': definition of dllimport function not allowed
      C:\dev\libpostal\headers\include\stdlib.h(685): error C2085: '_seterrormode': not in formal parameter list
      C:\dev\libpostal\headers\include\stdlib.h(685): error C2143: syntax error: missing ';' before 'type'
      C:\dev\libpostal\headers\include\stdlib.h(686): error C2085: '_sleep': not in formal parameter list
      C:\dev\libpostal\headers\include\stdlib.h(686): error C2143: syntax error: missing ';' before 'type'
      C:\dev\libpostal\headers\include\stdlib.h(707): error C2085: 'ecvt': not in formal parameter list
      C:\dev\libpostal\headers\include\stdlib.h(708): error C2085: 'fcvt': not in formal parameter list
      C:\dev\libpostal\headers\include\stdlib.h(709): error C2085: 'gcvt': not in formal parameter list
      C:\dev\libpostal\headers\include\stdlib.h(710): error C2085: 'itoa': not in formal parameter list
      C:\dev\libpostal\headers\include\stdlib.h(711): error C2085: 'ltoa': not in formal parameter list
      C:\dev\libpostal\headers\include\stdlib.h(712): error C2085: 'putenv': not in formal parameter list
      C:\dev\libpostal\headers\include\stdlib.h(716): error C2085: 'swab': not in formal parameter list
      C:\dev\libpostal\headers\include\stdlib.h(719): error C2085: 'ultoa': not in formal parameter list
      C:\dev\libpostal\headers\include\stdlib.h(720): error C2085: 'onexit': not in formal parameter list
      C:\dev\libpostal\headers\include\stdlib.h(726): error C2085: 'lldiv_t': not in formal parameter list
      C:\dev\libpostal\headers\include\stdlib.h(728): error C2061: syntax error: identifier 'lldiv_t'
      C:\dev\libpostal\headers\include\stdlib.h(732): error C2169: 'llabs': intrinsic function, cannot be defined
      C:\dev\libpostal\headers\include\mm_malloc.h(32): error C2054: expected '(' to follow '__inline__'
      C:\dev\libpostal\headers\include\mm_malloc.h(34): error C2085: '_mm_malloc': not in formal parameter list
      C:\dev\libpostal\headers\include\mm_malloc.h(34): error C2143: syntax error: missing ';' before '{'
      C:\dev\libpostal\headers\include\mm_malloc.h(72): error C2054: expected '(' to follow '__inline__'
      C:\dev\libpostal\headers\include\mm_malloc.h(73): error C2085: '_mm_free': not in formal parameter list
      C:\dev\libpostal\headers\include\mm_malloc.h(73): error C2143: syntax error: missing ';' before '{'
      C:\dev\libpostal\headers\include\malloc.h(125): error C2065: '_ALLOCA_S_MARKER_SIZE': undeclared identifier
      C:\dev\libpostal\headers\include\malloc.h(144): error C2065: '_ALLOCA_S_MARKER_SIZE': undeclared identifier
      C:\dev\libpostal\headers\include\math.h(209): error C2065: '__asm__': undeclared identifier
      C:\dev\libpostal\headers\include\math.h(209): error C2146: syntax error: missing ';' before identifier '__volatile__'
      C:\dev\libpostal\headers\include\math.h(209): warning C4013: '__volatile__' undefined; assuming extern returning int
      C:\dev\libpostal\headers\include\math.h(209): error C2143: syntax error: missing ')' before ':'
      C:\dev\libpostal\headers\include\math.h(220): error C2065: '__asm__': undeclared identifier
      C:\dev\libpostal\headers\include\math.h(220): error C2146: syntax error: missing ';' before identifier '__volatile__'
      C:\dev\libpostal\headers\include\math.h(220): error C2143: syntax error: missing ')' before ':'
      C:\dev\libpostal\headers\include\math.h(226): error C2169: 'fabs': intrinsic function, cannot be defined
      C:\dev\libpostal\headers\include\math.h(682): error C2169: 'sinhf': intrinsic function, cannot be defined
      C:\dev\libpostal\headers\include\math.h(688): error C2169: 'coshf': intrinsic function, cannot be defined
      C:\dev\libpostal\headers\include\math.h(694): error C2169: 'tanhf': intrinsic function, cannot be defined
      C:\dev\libpostal\headers\include\math.h(718): error C2169: 'expf': intrinsic function, cannot be defined
      C:\dev\libpostal\headers\include\math.h(891): error C2169: 'powf': intrinsic function, cannot be defined
      C:\dev\libpostal\headers\include\math.h(1157): error C2065: '__asm__': undeclared identifier
      C:\dev\libpostal\headers\include\math.h(1157): error C2146: syntax error: missing ';' before identifier '__volatile__'
      C:\dev\libpostal\headers\include\math.h(1158): error C2143: syntax error: missing ')' before ':'
      C:\dev\libpostal\headers\include\sys/types.h(68): error C2371: 'pid_t': redefinition; different basic types
      C:\Users\My ser\miniconda3\envs\myenv\include\pyconfig.h(190): note: see declaration of 'pid_t'
      error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\VC\\Tools\\MSVC\\14.28.29333\\bin\\HostX86\\x64\\cl.exe' failed with exit code 2
      [end of output]
    

    note: This error originates from a subprocess, and is likely not a problem with pip. error: legacy-install-failure

    × Encountered error while trying to install package. ╰─> postal

    note: This is an issue with the package mentioned above, not pip. hint: See above for output from the failure.

    opened by bdaveh360 6
  • No such file or directory:  'README.rst'

    No such file or directory: 'README.rst'

    Hi Team, I am using windows 11 and while I am running 'pip install pyPostal' on command prompt, getting below error No such file or directory: 'README.rst' kindly look into this if anyone has solution, I have also attached the screenshot of error. Thank You pypostal_error_cmd pypostal_error_cmd2

    opened by ragvendra3898 1
  • ERROR: hashes = libpostal_near_dupe_name_hashes(input, options, &num_hashes)

    ERROR: hashes = libpostal_near_dupe_name_hashes(input, options, &num_hashes)

    building 'postal._near_dupe' extension
          gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/rjurney/opt/anaconda3/envs/deep_discovery/include -arch x86_64 -I/Users/rjurney/opt/anaconda3/envs/deep_discovery/include -arch x86_64 -I/usr/local/opt/openjdk/include -I/usr/local/include -I/Users/rjurney/opt/anaconda3/envs/deep_discovery/include/python3.8 -c postal/pyneardupe.c -o build/temp.macosx-10.9-x86_64-3.8/postal/pyneardupe.o -std=c99
          postal/pyneardupe.c:139:14: error: implicit declaration of function 'libpostal_near_dupe_name_hashes' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
              hashes = libpostal_near_dupe_name_hashes(input, options, &num_hashes);
                       ^
          postal/pyneardupe.c:139:14: note: did you mean 'libpostal_near_dupe_hashes'?
          /usr/local/include/libpostal/libpostal.h:209:25: note: 'libpostal_near_dupe_hashes' declared here
          LIBPOSTAL_EXPORT char **libpostal_near_dupe_hashes(size_t num_components, char **labels, char **values, libpostal_near_dupe_hash_options_t options, size_t *num_hashes);
                                  ^
          postal/pyneardupe.c:139:12: warning: incompatible integer to pointer conversion assigning to 'char **' from 'int' [-Wint-conversion]
              hashes = libpostal_near_dupe_name_hashes(input, options, &num_hashes);
                     ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          1 warning and 1 error generated.
          error: command 'gcc' failed with exit status 1
          ----------------------------------------
        Rolling back uninstall of postal
        Moving to /Users/rjurney/opt/anaconda3/envs/deep_discovery/lib/python3.8/site-packages/postal-1.1.9.dist-info/
         from /Users/rjurney/opt/anaconda3/envs/deep_discovery/lib/python3.8/site-packages/~ostal-1.1.9.dist-info
        Moving to /Users/rjurney/opt/anaconda3/envs/deep_discovery/lib/python3.8/site-packages/postal/
         from /Users/rjurney/opt/anaconda3/envs/deep_discovery/lib/python3.8/site-packages/~ostal
      ERROR: Command errored out with exit status 1: /Users/rjurney/opt/anaconda3/envs/deep_discovery/bin/python -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/3h/vnn5rkyx3nx7yyrfyynrhrlw0000gn/T/pip-req-build-fqvy9nf0/setup.py'"'"'; __file__='"'"'/private/var/folders/3h/vnn5rkyx3nx7yyrfyynrhrlw0000gn/T/pip-req-build-fqvy9nf0/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/3h/vnn5rkyx3nx7yyrfyynrhrlw0000gn/T/pip-record-fzt_fdcr/install-record.txt --single-version-externally-managed --compile --install-headers /Users/rjurney/opt/anaconda3/envs/deep_discovery/include/python3.8/postal Check the logs for full command output.
    
    opened by rjurney 2
Releases(1.0)
Owner
openvenues
An open source project sponsored by Mapzen.
openvenues
This is a simple python code to get IP address and its location using python

IP address & Location finder @DEV/ED : Pavan Ananth Sharma Dependencies: ip2geotools Note: use pip install ip2geotools to install this in your termin

Pavan Ananth Sharma 2 Jul 5, 2022
Python bindings and utilities for GeoJSON

geojson This Python library contains: Functions for encoding and decoding GeoJSON formatted data Classes for all GeoJSON Objects An implementation of

Jazzband 765 Jan 6, 2023
Python bindings and utilities for GeoJSON

geojson This Python library contains: Functions for encoding and decoding GeoJSON formatted data Classes for all GeoJSON Objects An implementation of

Jazzband 763 Dec 26, 2022
Program that shows all the details of the given IP address. Build with Python and ipinfo.io API

ip-details This is a program that shows all the details of the given IP address. Build with Python and ipinfo.io API Usage To use this program, run th

null 4 Mar 1, 2022
Pandas Network Analysis: fast accessibility metrics and shortest paths, using contraction hierarchies :world_map:

Pandana Pandana is a Python library for network analysis that uses contraction hierarchies to calculate super-fast travel accessibility metrics and sh

Urban Data Science Toolkit 321 Jan 5, 2023
Mmdb-server - An open source fast API server to lookup IP addresses for their geographic location

mmdb-server mmdb-server is an open source fast API server to lookup IP addresses

Alexandre Dulaunoy 67 Nov 25, 2022
GeoIP Legacy Python API

MaxMind GeoIP Legacy Python Extension API Requirements Python 2.5+ or 3.3+ GeoIP Legacy C Library 1.4.7 or greater Installation With pip: $ pip instal

MaxMind 230 Nov 10, 2022
Geocoding library for Python.

geopy geopy is a Python client for several popular geocoding web services. geopy makes it easy for Python developers to locate the coordinates of addr

geopy 3.8k Dec 30, 2022
Python Data. Leaflet.js Maps.

folium Python Data, Leaflet.js Maps folium builds on the data wrangling strengths of the Python ecosystem and the mapping strengths of the Leaflet.js

null 6k Jan 2, 2023
Python tools for geographic data

GeoPandas Python tools for geographic data Introduction GeoPandas is a project to add support for geographic data to pandas objects. It currently impl

GeoPandas 3.5k Jan 3, 2023
Python interface to PROJ (cartographic projections and coordinate transformations library)

pyproj Python interface to PROJ (cartographic projections and coordinate transformations library). Documentation Stable: http://pyproj4.github.io/pypr

null 832 Dec 31, 2022
Documentation and samples for ArcGIS API for Python

ArcGIS API for Python ArcGIS API for Python is a Python library for working with maps and geospatial data, powered by web GIS. It provides simple and

Esri 1.4k Dec 30, 2022
PySAL: Python Spatial Analysis Library Meta-Package

Python Spatial Analysis Library PySAL, the Python spatial analysis library, is an open source cross-platform library for geospatial data science with

Python Spatial Analysis Library 1.1k Dec 18, 2022
Simple, concise geographical visualization in Python

Geographic visualizations for HoloViews. Build Status Coverage Latest dev release Latest release Docs What is it? GeoViews is a Python library that ma

HoloViz 445 Jan 2, 2023
A package built to support working with spatial data using open source python

EarthPy EarthPy makes it easier to plot and manipulate spatial data in Python. Why EarthPy? Python is a generic programming language designed to suppo

Earth Lab 414 Dec 23, 2022
pure-Python (Numpy optional) 3D coordinate conversions for geospace ecef enu eci

Python 3-D coordinate conversions Pure Python (no prerequistes beyond Python itself) 3-D geographic coordinate conversions and geodesy. API similar to

Geospace code 292 Dec 29, 2022
:earth_asia: Python Geocoder

Python Geocoder Simple and consistent geocoding library written in Python. Table of content Overview A glimpse at the API Forward Multiple results Rev

Denis 1.5k Jan 2, 2023
Python package for earth-observing satellite data processing

Satpy The Satpy package is a python library for reading and manipulating meteorological remote sensing data and writing it to various image and data f

PyTroll 882 Dec 27, 2022
Use Mapbox GL JS to visualize data in a Python Jupyter notebook

Location Data Visualization library for Jupyter Notebooks Library documentation at https://mapbox-mapboxgl-jupyter.readthedocs-hosted.com/en/latest/.

Mapbox 620 Dec 15, 2022