libpostal icon indicating copy to clipboard operation
libpostal copied to clipboard

M1 Mac woes using libpostal

Open bdiller-interos opened this issue 2 years ago • 14 comments

Hi!

I tried installing libpostal on M1 Mac through these two methods listed below:

  1. https://github.com/openvenues/libpostal#installation-maclinux
  2. https://ports.macports.org/port/libpostal

I cannot use the parser api using the python bindings when library is installed by (1) or (2).

For example, after I installed the postal package in my python 3.8.6 virtual environment, i.e.,pip install postal, I am receiving this consistent error when doing a simple import :

venv) libpostal % python Python 3.8.6 (v3.8.6:db455296be, Sep 23 2020, 13:31:39) [Clang 6.0 (clang-600.0.57)] on darwin Type "help", "copyright", "credits" or "license" for more information.

from postal.parser import parse_address Traceback (most recent call last): File "", line 1, in File "/Users/bdiller/gitlab/project/venv/lib/python3.8/site-packages/postal/parser.py", line 2, in from postal import _parser ImportError: dlopen(/Users/bdiller/gitlab/project/venv/lib/python3.8/site-packages/postal/_parser.cpython-38-darwin.so, 0x0002): symbol not found in flat namespace '_libpostal_address_parser_response_destroy'

What is wrong?

bdiller-interos avatar Jun 15 '22 17:06 bdiller-interos

What you can do:

  • start the terminal in Rosetta mode. If you type in arch it should say i386
  • add the --disable-sse2 flag ( because https://github.com/openvenues/libpostal/issues/551 )

If it still does not work try to use Python 3.9 or 3.10. I was able to get it working by switching from 3.8 to 3.9 or 3.10. Then the nasty error message "symbol not found in flat namespace '_libpostal_address_parser_response_destroy'" went away.

JochenFromm avatar Jul 21 '22 13:07 JochenFromm

What you can do:

If it still does not work try to use Python 3.9 or 3.10. I was able to get it working by switching from 3.8 to 3.9 or 3.10. Then the nasty error message "symbol not found in flat namespace '_libpostal_address_parser_response_destroy'" went away.

I have tried the mentioned steps but it still dint work. My arch is 'AMD64'. I have also tried swithcing to 3.9. It still doesnt work. Any help on this would be appreciated

Gayathri2993 avatar Mar 28 '23 22:03 Gayathri2993

I am facing the same issue with M2 Mac I tried using all the methods but it does not work out for me if @albarrentine or @JochenFromm or anyone who could help to resolve this issue is really appreciated.

varunpawar652000 avatar Jun 14 '23 21:06 varunpawar652000

% gcc -v Apple clang version 14.0.3 (clang-1403.0.22.14.1) Target: arm64-apple-darwin22.5.0 Thread model: posix InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

Here is exactly what I did and make check succeeds:

brew install curl autoconf automake libtool pkg-config
mkdir test
cd test
git clone https://github.com/openvenues/libpostal
cd libpostal
./bootstrap.sh
./configure --datadir=/tmp/libpostal --prefix=$PWD MODEL=senzing
make -j16 install
make check

I tried --disable-sse2 like configure suggests but it looks like someone auto-detected the ARM architecture to disable that automatically and if you actually specify --disable-sse2 it breaks things. I have an M1 but I doubt that matters here.

brianmacy avatar Jun 14 '23 22:06 brianmacy

This works for me. Thanks ❤️ Could you also help me in that how I can use it for python.

>>> from postal import _parser
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: dlopen(/Users/varunpawar/.pyenv/versions/3.8.13/lib/python3.8/site-packages/postal/_parser.cpython-38-darwin.so, 0x0002): tried: '/Users/varunpawar/.pyenv/versions/3.8.13/lib/python3.8/site-packages/postal/_parser.cpython-38-darwin.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64')), '/System/Volumes/Preboot/Cryptexes/OS/Users/varunpawar/.pyenv/versions/3.8.13/lib/python3.8/site-packages/postal/_parser.cpython-38-darwin.so' (no such file), '/Users/varunpawar/.pyenv/versions/3.8.13/lib/python3.8/site-packages/postal/_parser.cpython-38-darwin.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64'))

varunpawar652000 avatar Jun 15 '23 00:06 varunpawar652000

Run file /Users/varunpawar/.pyenv/versions/3.8.13/lib/python3.8/site-packages/postal/_parser.cpython-38-darwin.so

Then the same on the python executable that you are running. It looks like the postal binaries that you installed with pip are Intel x86_64 and your python is arm64. Make sure your pip is also arm64 as that would be required for you to get the right Python packages... though I really have no experience with the Python bindings, so can't help. You might want to file an issue on that project (I think it is separate).

brianmacy avatar Jun 15 '23 02:06 brianmacy

I have the same issue. Will not run in python 3.7 or 3.8, works with 3.9. I am using python in a conda environment. I attempted to solve this using both Rosetta and Native terminals as well as Rosetta and Native Homebrew. The --disable-sse2 flag did not work for me, but upgrading to python 3.9 then doing a pip install did solve the problem.

On a Mac M2 Max. % gcc -v Apple clang version 14.0.3 (clang-1403.0.22.14.1) Target: x86_64-apple-darwin22.5.0 Thread model: posix InstalledDir: /Library/Developer/CommandLineTools/usr/bin

wiseyoungbuck avatar Jun 21 '23 20:06 wiseyoungbuck

Main reason is pypostal uses a particular includes and bin directory and for Mac some times that would not be that we have in pypostal. So to resolve the issue I install python 3.10 and tweaked my path for libpostal includes and bin.

varunpawar652000 avatar Jun 21 '23 21:06 varunpawar652000

i am using pyspark and getting below error on mac M1. i tired to use python 3.9 version too . It is working with python but not with pyspark : ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/postal/_parser.cpython-310-darwin.so, 0x0002): symbol not found in flat namespace '_libpostal_address_parser_response_destroy'

@varunpawar652000 can you share on how you set the path ?

nikil-katturi avatar Sep 21 '23 17:09 nikil-katturi

@nikil-katturi can you please share your python version?

varunpawar652000 avatar Sep 21 '23 17:09 varunpawar652000

python version 3.10

nikil-katturi avatar Sep 21 '23 17:09 nikil-katturi

Is pypostal is working as you want? Like with out pyspark are you able to use pypostal?

varunpawar652000 avatar Sep 21 '23 17:09 varunpawar652000

yes it is working without pyspark

nikil-katturi avatar Sep 21 '23 17:09 nikil-katturi