| .. | ||
| tests | ||
| AssetList.py | ||
| README.md | ||
| requirements.txt | ||
libpostal Installation Guide for macOS M1
Overview
libpostal is a fast, open-source address parsing and normalization library, designed for global addresses. This guide
provides detailed steps to install libpostal on macOS with Apple Silicon (M1/M2) and use it with Python.
📌 Prerequisites
Before installing libpostal, ensure you have the necessary dependencies installed.
1️⃣ Install Required Dependencies
Open a terminal and run:
brew install curl autoconf automake libtool pkg-config
2️⃣ Clone the libpostal Repository
git clone https://github.com/openvenues/libpostal.git
cd libpostal
3️⃣ Run Bootstrap Script
./bootstrap.sh
4️⃣ Configure the Build (Important for M1 Macs)
Since M1 chips do not support SSE2 natively, you must disable SSE2 for compatibility.
./configure --disable-sse2 --datadir=/usr/local/libpostal_data
(You can replace /usr/local/libpostal_data with another directory that has a few GB of space.)
5️⃣ Compile and Install
make -j$(sysctl -n hw.ncpu)
sudo make install
6️⃣ Install Python Bindings
Once libpostal is installed, install the Python package:
pip install postal
✅ Verify Installation
To check if libpostal was installed successfully, run:
python -c "import postal; print(postal.parser.parse('23 Clifton Hill, Newtown, Exeter, EX1 2DL'))"
Expected Output:
[('23', 'house_number'), ('Clifton Hill', 'road'), ('Newtown', 'city'), ('Exeter', 'city'), ('EX1 2DL', 'postcode')]
📌 Usage Example in Python
Address Parsing
from postal.parser import parse
address = "23 Clifton Hill, Newtown, Exeter, EX1 2DL"
parsed_address = dict(parse(address))
print(parsed_address)
Expected Output:
{
'house_number': '23',
'road': 'Clifton Hill',
'city': 'Newtown',
'city': 'Exeter',
'postcode': 'EX1 2DL'
}
Address Normalization
from postal.normalize import normalize_string
address = "Block (Rooms 1-4), 23 Clifton Hill, Newtown, Exeter, EX1 2DL"
normalized = normalize_string(address)
print(normalized)
📌 Troubleshooting
1️⃣ libpostal Not Found?
If you encounter an error like ModuleNotFoundError: No module named 'postal', make sure:
- You ran
sudo make install - Your Python environment recognizes
postal. Try:pip install postal --no-cache-dir - If using a virtual environment (
venv), activate it before running Python.
2️⃣ Compilation Issues on macOS?
If make fails, try running:
brew reinstall autoconf automake libtool pkg-config
Then restart the installation process.
3️⃣ Can't Find libpostal Data Directory?
Ensure libpostal_data exists in the correct directory:
ls /usr/local/libpostal_data
If missing, re-run ./configure with the correct path.
🛠 Uninstallation
To remove libpostal, run:
sudo rm -rf /usr/local/lib/libpostal*
sudo rm -rf /usr/local/include/libpostal*
rm -rf ~/libpostal
pip uninstall postal