BLLIP / bllip-parser

BLLIP reranking parser (also known as Charniak-Johnson parser, Charniak parser, Brown reranking parser) See http://pypi.python.org/pypi/bllipparser/ for Python module.
http://bllip.cs.brown.edu/
227 stars 53 forks source link

MacOS: Compiled successfully, but module is missing #53

Open fhamborg opened 7 years ago

fhamborg commented 7 years ago

I'm on MacOS 10.12.3 and followed the hints in the other issue on failing MacOS compilation (#19). Finally, I was able to get the compilation and python package setup run through, but I still cannot use the parser.

fxa:~ felix$ python3
Python 3.6.0 (v3.6.0:41df79263a11, Dec 22 2016, 17:23:13)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import bllipparser
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/bllipparser-2016.9.11-py3.6-macosx-10.6-intel.egg/bllipparser/CharniakParser.py", line 14, in swig_import_helper
    return importlib.import_module(mname)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 978, in _gcd_import
  File "<frozen importlib._bootstrap>", line 961, in _find_and_load
  File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 648, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 560, in module_from_spec
  File "<frozen importlib._bootstrap_external>", line 922, in create_module
  File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/bllipparser-2016.9.11-py3.6-macosx-10.6-intel.egg/bllipparser/_CharniakParser.cpython-36m-darwin.so, 2): no suitable image found.  Did find:
    /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/bllipparser-2016.9.11-py3.6-macosx-10.6-intel.egg/bllipparser/_CharniakParser.cpython-36m-darwin.so: mach-o, but wrong architecture

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/bllipparser-2016.9.11-py3.6-macosx-10.6-intel.egg/bllipparser/__init__.py", line 399, in <module>
    from .RerankingParser import RerankingParser, Tree, Sentence, tokenize
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/bllipparser-2016.9.11-py3.6-macosx-10.6-intel.egg/bllipparser/RerankingParser.py", line 19, in <module>
    from . import CharniakParser as parser
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/bllipparser-2016.9.11-py3.6-macosx-10.6-intel.egg/bllipparser/CharniakParser.py", line 17, in <module>
    _CharniakParser = swig_import_helper()
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/bllipparser-2016.9.11-py3.6-macosx-10.6-intel.egg/bllipparser/CharniakParser.py", line 16, in swig_import_helper
    return importlib.import_module('_CharniakParser')
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
ModuleNotFoundError: No module named '_CharniakParser'
>>>
dmcc commented 7 years ago

Sadly, I'm no expert on building BLLIP on Mac OS X (still). Is http://stackoverflow.com/questions/26958232/need-help-wrong-architecture-causing-app-to-crash-when-launching-in-ios-7-but helpful?

fhamborg commented 7 years ago

Unfortunately not, but I managed to avoid this problem by basically performing PyCharm remote development, i.e., I setup a Ubuntu VM which is now controlled by PyCharm. The code is executed on that VM rather than on MacOS. It's not good, but it works. I followed this guide: https://blog.jetbrains.com/pycharm/2015/03/feature-spotlight-python-remote-development-with-pycharm/

namkhanhtran commented 7 years ago

here is what I did to solve this problem on Mac el Capitan

  1. of course, install swig with brew: brew install swig
  2. in order to run: make (to compile), I need to specify the CC and CXX as stated in the README: CC=/usr/lib/bin/gcc-7 and CXX=/usr/lib/bin/g++-7
  3. I tried to install the python package using pip install bllipparser, but got the same error. So, I decided to install from source code with python setup.py install. But the trick here is that I NEED to use the default CC and CXX (just open a new terminal :- ) )
  4. Probably, one error (Expected in: flat namespace) will be returned, just add “‘-stdlib=libc++’” when building reranker_module in setup.py, instead of c++11. (https://stackoverflow.com/questions/16880571/why-does-clang-lack-forward-list)

Good luck ;-)