Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

M1 Mac woes using libpostal #585

Open
bdiller-interos opened this issue Jun 15, 2022 · 13 comments
Open

M1 Mac woes using libpostal #585

bdiller-interos opened this issue Jun 15, 2022 · 13 comments

Comments

@bdiller-interos
Copy link

bdiller-interos commented Jun 15, 2022

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 bdiller-interos changed the title I M1 Mac woes using libpostal Jun 15, 2022
@JochenFromm
Copy link

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.

@Gayathri2993
Copy link

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

@varunpawar652000
Copy link

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.

@brianmacy
Copy link

brianmacy commented Jun 14, 2023

% 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.

@varunpawar652000
Copy link

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'))

@brianmacy
Copy link

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).

@wiseyoungbuck
Copy link

wiseyoungbuck commented Jun 21, 2023

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

@varunpawar652000
Copy link

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.

@nikil-katturi
Copy link

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 ?

@varunpawar652000
Copy link

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

@nikil-katturi
Copy link

python version 3.10

@varunpawar652000
Copy link

varunpawar652000 commented Sep 21, 2023

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

@nikil-katturi
Copy link

yes it is working without pyspark

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants