Open StellaWeiyiChen opened 4 years ago
You'll find precompiled packages for version 4.2 in the "releases" section. They include python APIs
I tried using the precompiled package (for MacOS). Was receiving ImportError
, so followed the instructions here by setting DYLD_LIBRARY_PATH
, but I'm still getting the same ImportError
.
I checked this issue.
For some reason, python module loader expects the module to be called _pyfreeling.so instead of _pyfreeling.dylib (maybe this is a CMake or swig issue)
If you rename or copy _pyfreeling.dylib to _pyfreeling.so it should work
The precompiled package already includes an alias _pyfreeling.so that points to _pyfreeling.dylib. When I delete this alias and rename the .dylib to .so, the problem persists.
DYLD_LIBRARY_PATH: /usr/local/lib:/usr/local/share/freeling/APIs/python3
Traceback (most recent call last):
File "sample.py", line 10, in <module>
import pyfreeling
File "/usr/local/share/freeling/APIs/python3/pyfreeling.py", line 15, in <module>
import _pyfreeling
ImportError: dlopen(/usr/local/share/freeling/APIs/python3/_pyfreeling.so, 2): Symbol not found: __ZN5boost16re_detail_10720011raw_storage6insertEmm
Referenced from: /usr/local/lib/libfreeling.dylib
Expected in: /usr/local/lib/libboost_regex-mt.dylib
in /usr/local/lib/libfreeling.dylib
Perhaps this may be the reason?
I've tried compiling everything as described in the documentation and then renaming the .dylib to .so, as well, but doing this gave Seg faults for some reason.
That is a different problem.
It is now finding the library, but then there is a problem with some of the boost dependencies.
It may be you have more than one boost installed, and the loader is finding the wrong one.
It also may be as the stackoverflow link says, that you boost is compiled differntly.
It also may be that your boost version is different than the one with which the package was built
Did you install boost using brew ?
I also uploaded a new .pkg that has _pyfreeling.so compiled as a MODULE and not as SHARED (cmake stuff) which is supposed to be the right way for this case. You can try downloading it again.
I updated my brew boost version and I get the same error now. So, the cause is that you have a different version than the one the package was built with.
The safest way will be rebuilding the API. Get lastest git master version and compile again. Cmake should build the .so library instead of the .dylib. Install it on a clean directory.
I have installed everything with brew and currently have the most recent versions of all dependencies described here.
I built from the latest git master version and I am getting a seg fault: Segmentation fault: 11
.
I made the package with the following (and I properly export $FLINSTALL to a directory on my system):
* in $FLINSTALL *
mkdir build
cd build
cmake .. -DICU_ROOT=/usr/local/opt/icu4c -DCMAKE_INSTALL_PREFIX=$FLINSTALL -DPYTHON3_API=ON
make -j 4 install
I tried renaming the _pyfreeling.so to _pyfreeling.dylib and created an alias with the name _pyfreeling.so, and this also did not work; I got an ImportError: no suitable image found
.
When you recompiled, did the python3 API work for you?
Yes, it worked for me. in latest master, CMake generates the .so file and not the .dylib, so there is no need to rename it. Make sure you remove all previous installation and build it all again from scratch
The segfault maybe due to differnt reasons. Did the C++ main "analyze -f en.cfg " work properly ?
Yes, the main C++ analyze -f en.cfg
works properly. Perhaps I'm not running the script correctly? Right now I just go to $FLINSTALL/share/freeling/APIs/python3
and then run python sample.py
. I am using python 3.8.
I get the segfault the moment I try and import pyfreeling
I'm sure my paths (DYLD_LIBRARY_PATH
) are all set correctly.
SWIG: 4.02 icu4c: 67.1 boost: 1.73.0
I was able to get it to work - it was because I had multiple versions of python installed. It was building everything with python 3.8 but I was using anaconda python 3.7.6.
Thanks for your help with this!
Hello @lluisp. Thank you for developing such a wonderful tool for language processing. I'm having the same problem as @matt-nam. I compiled FreeLing 4.2 from source on macOS 11.1 to use with python.
SWIG: 4.0.2 icu4c: 67.1 boost: 1.75.0 Python: 3.9.0
I'm having the same issue where analyze -f en.cfg
works fine, but when I set my directory to /usr/local/share/freeling/APIs/python3
and run python3 sample.py < mytext.txt
I get the error ImportError: dlopen(/usr/local/share/freeling/APIs/python3/_pyfreeling.so, 2): Library not loaded: @rpath/libfreeling.dylib Referenced from: /usr/local/share/freeling/APIs/python3/_pyfreeling.so Reason: image not found
I renamed _pyfreeling.dylib to _pyfreeling.so and I got the error ModuleNotFoundError: No module named '_pyfreeling'
@matt-nam how did you solve your issue with having multiple versions installed? I would appreciate any insight into this issue, as it seems to be recurrent. Thanks.
It looks as if the loader is not finding the binary library libfreeling.dylib make sure the path to this library is in included in the env variable DYLD_LIBRARY_PATH
Hello, I followed your instructions to build freeling from source to use it as a python3 API. However, checking all the step, running python sample.py > sample.txt still show _pyfreeling module not found. I checked that my DYLD_LIBRARY_PATH was correct with usr/local/lib and usr/local/share/freeling/APIs/python3. Any insight about why? thanks in advance.