dmitriy-serdyuk / kaldi-python

Python wrappers for Kaldi data
Apache License 2.0
34 stars 18 forks source link

No module named kaldi_io_internal #5

Closed justinmaojones closed 8 years ago

justinmaojones commented 8 years ago

Hello, I cloned this repo and installed using pip install -e . --user

I then ran python -c "import kaldi_io" and got the following error:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/jmj418/kaldi-python/kaldi_io/__init__.py", line 243, in <module>
    from kaldi_io_internal import *
ImportError: No module named kaldi_io_internal
justinmaojones commented 8 years ago

When I run python setup.py install instead, I run into the error identified in https://github.com/dmitriy-serdyuk/kaldi-python/issues/3

dmitriy-serdyuk commented 8 years ago

That's because the build directory is not your PATH. Try to run

LD_LIBRARY_PATH=<path_to_kaldi_python>/build/<path_to_so> python -c "import kaldi_io_internal"
justinmaojones commented 8 years ago

I think the problem I was having was that kaldi_io_internal.cpp was not compiling, and so the .so file was never generated. It seems that kaldi-python was looking for the Python2.7 library in /usr/local, despite having the correct path to the python library set in LD_LIBRARY_PATH. I was able to get it to compile by adding

LDFLAGS=-L/usr/local/pkg/python/2.7.3/lib

to the kaldi-python/kaldi_io/Makefile, and python setup.py install --user seemed to complete successfully. However, now I get the following error:

Python 2.7.3 (default, Mar  5 2013, 16:35:34)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import kaldi_io
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "kaldi_io/__init__.py", line 243, in <module>
    from kaldi_io_internal import *
ImportError: libfst.so.1: cannot open shared object file: No such file or directory

I also had to add $KALDI_ROOT/tools/openfst/lib/ to LD_LIBRARY_PATH. It seems to be working now. Thanks.

alisa5 commented 8 years ago

i think i have the same problem here,but after add LDFLAGS to the kaldi-python/kaldi_io/Makefile,I still hav error when making kaldi_io as followed:

/usr/bin/ld: cannot find -lpython2.7 collect2: error: ld returned 1 exit status make64: *\ [kaldi_io_internal.so] Error 1