Today, I tried to follow the same procedures to install GHMM in my another Ubuntu and Debian system on another two PCs, but got some problems.
After installing the GHMM as well as the Python bindings, I imported ghmm in iPython but got errors:
ImportError: libghmm.so.1: cannot open shared object file: No such file or directory
I tried to find out whether libghmm.so.1 was installed by using
$ sudo updatedb
$ locate libghmm.so.1
then got
~/ghmm/ghmm/.libs/libghmm.so.1
~/ghmm/ghmm/.libs/libghmm.so.1.0.0
/usr/local/lib/libghmm.so.1
/usr/local/lib/libghmm.so.1.0.0
The messages indicated that the libghmm.so.1 had been in my system, but the Python somehow couldn't find it. So there must be some setting needed to make it work.
There have been some discussions in the mailing lists of GHMM as follows.
[Ghmm-list] cant find _ghmmwrapper
[Ghmm-list] ImportError: libghmm.so.1 ...
With the above information, I add the LD_LIBRARY_PATH into .bashrc as
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
It works. :-)
---
Some information found during my solution-searching:
- Understanding imports and PYTHONPATH
- Program Library HOWTO
- LD_LIBRARY_PATH Is Not The Answer
- Why LD_LIBRARY_PATH is bad
---
memo (090923): I found the libghmm.so.1 file has been in the path of ``/usr/lib/'' instead of ``/usr/local/lib/'' in the first Ubuntu PC which has ghmm installed without any problem. Therefore I tried to cp the libghmm.so.1 file into the path of /usr/lib/ for the other two PCs and everything is okay now.
You are genius. I've been trying to get this sorted all day! Thanks!
ReplyDeleteYou are welcome. It's good to know that my post helps.
ReplyDeleteThank you very much for the trick!
ReplyDeleteThanks for the note! It helped me a lot :)
ReplyDeleteThat was very helpful.
ReplyDeleteIf you want to avoid having to set the LD_LIBRARY_PATH, which is bad, you can add the following line at the top of ghmmwrapper.py
ReplyDeleteOf course, replace /usr/local/lib' by the dir where libghmm.so.1 is.
Works for me...!
# TBM HACK
import imp
fp = None
try:
fp, pathname, description = imp.find_module('libghmm', ['/usr/local/lib'])
except ImportError:
print 'ghmmwrapper.py: TBM HACK FAILED'
if fp is not None:
try:
imp.load_module('libghmm', fp, pathname, description)
except ImportError:
pass
finally:
fp.close()
Thanks, Thierry BM. I didn't know the imp module. Your approach is more like ``Python way.''
ReplyDeleteAwesome, this just worked.
ReplyDelete