liangy1969 / CRF-RNN_Tensorflow

Tensorflow implementation of CRF-RNN
13 stars 10 forks source link

ImportError: No module named _permutohedral #1

Open molyswu opened 7 years ago

molyswu commented 7 years ago

Hi, python main_example.py Traceback (most recent call last): File "main_example.py", line 5, in import CRFRNN File "/home/molys/product/NER/CRF-RNN_Tensorflow/CRFRNN.py", line 8, in import permutohedral File "/home/molys/product/NER/CRF-RNN_Tensorflow/permutohedral.py", line 17, in _permutohedral = swig_import_helper() File "/home/molys/product/NER/CRF-RNN_Tensorflow/permutohedral.py", line 16, in swig_import_helper return importlib.import_module('_permutohedral') File "/usr/lib64/python2.7/importlib/init.py", line 37, in import_module import(name) ImportError: No module named _permutohedral

0ohadeso0 commented 7 years ago

hi, i have the same problem. Did you fix that?

liangy1969 commented 7 years ago

The code runs with no problem on my personal computer and the computer in my office. The lib is complied under win64, so that might be the cause. Anyway, I will upload the source files of the lib in the following days so that you can compile them by yourself.

onurbarut commented 7 years ago

hi, while running setup.py I get the following error. do you have any idea?

onur@onur-GE62VR-6RF:~/tf_kodlar/CRF-RNN_Tensorflow-master/src$ python3 setup.py build_ext --inplace running build_ext building '_permutohedral' extension x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/lib/python3.5/Lib/site-packages/numpy/core/include -I/usr/include/python3.5m -c permutohedral_wrap.cxx -o build/temp.linux-x86_64-3.5/permutohedral_wrap.o cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++ permutohedral_wrap.cxx: In function ‘PyObject _wrap_PermutohedralLattice_get_enclosing_simplices(PyObject, PyObject)’: permutohedral_wrap.cxx:4056:10: error: invalid conversion from ‘long long unsigned int’ to ‘size_t {aka long unsigned int}’ [-fpermissive] arg2 = (unsigned long long) array_data(array2); ^ permutohedral_wrap.cxx: In function ‘PyObject _wrap_PermutohedralLattice_get_blur(PyObject, PyObject)’: permutohedral_wrap.cxx:4166:10: error: invalid conversion from ‘long long unsigned int’ to ‘size_t {aka long unsigned int}’ [-fpermissive] arg2 = (unsigned long long) array_data(array2); ^ error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

Thanks for the code.

liangy1969 commented 7 years ago

What is the numpy version you are using?

onurbarut commented 7 years ago

it is 1.13.3. if you need, i use python3.5. If you would like to check it out, I asked a question in stackoverflow, with a little more detail explained. https://stackoverflow.com/questions/46593778/building-crf-rnn-tensorflow-implementation

liangy1969 commented 7 years ago

You can try installing the following packages: sudo apt-get install build-essential libssl-dev libffi-dev python3-dev

I am not sure whether it can work, but you can have a try.

onurbarut commented 7 years ago

it did not work. At the step 5, I run with python3 setup.py.... right? And what is the $PYTHON_PATH you mentioned at the step 4? Maybe I wrote a wrong path. How can I determine what is my path? Thanks for your concern

liangy1969 commented 7 years ago

Try changing '$PYTHON_PATH/Lib/site-packages/numpy/core/include' to '/usr/local/lib/python3.5/dist-packages/numpy/core/include/numpy', or the folder that contains the header files of numpy in your python directory.

onurbarut commented 7 years ago

I did, actually I modified setup with import and np.get_include() instead of whole pathname. No use, same error remains :(

liangy1969 commented 7 years ago

Probably the 'permutohedral_wrap.cxx' you generated using swig is not correct. Try using the following one permutohedral_wrap.txt Change the suffix to cxx

onurbarut commented 7 years ago

You are correct. The problem seems to be solved. I will let you know when I truly train the CRF. Thanks.