Search code examples
python-3.xpython-importdynet

ImportError libdynet.so: cannot open shared object file, No such file or directory


Today I tried to run a simple dynet program (that I ran several months ago with no problems), and got the following error:

Traceback (most recent call last):
  File "/home/erelsgl/Dropbox/dicta/text-taggers/test_dynet.py", line 1, in <module>
    import dynet
  File "/usr/local/lib/python3.5/dist-packages/dyNET-0.0.0-py3.5-linux-x86_64.egg/dynet.py", line 17, in <module>
    from _dynet import *
ImportError: libdynet.so: cannot open shared object file: No such file or directory

I get the same error even with a minimal program that only contains "import dynet".

I tried to re-install dynet in several ways:

$ sudo pip3 install dynet
Requirement already satisfied: dynet in /usr/local/lib/python3.5/dist-packages/dyNET-0.0.0-py3.5-linux-x86_64.egg (0.0.0)
Requirement already satisfied: cython in /usr/local/lib/python3.5/dist-packages (from dynet) (0.25.2)
Requirement already satisfied: numpy in /usr/local/lib/python3.5/dist-packages (from dynet) (1.12.1)

and also:

$ sudo -H pip3 install git+https://github.com/clab/dynet#egg=dynet
Requirement already satisfied: dynet from git+https://github.com/clab/dynet#egg=dynet in /usr/local/lib/python3.5/dist-packages/dyNET-0.0.0-py3.5-linux-x86_64.egg (0.0.0)
Requirement already satisfied: cython in /usr/local/lib/python3.5/dist-packages (from dynet) (0.25.2)
Requirement already satisfied: numpy in /usr/local/lib/python3.5/dist-packages (from dynet) (1.12.1)

But the program still does not work... what can I do?

EDIT: Here is the python version in the command line:

Python 3.5.2 (default, Nov 12 2018, 13:43:14) 
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> print(sys.path)
['', '/usr/lib/python35.zip', '/usr/lib/python3.5', '/usr/lib/python3.5/plat-x86_64-linux-gnu', '/usr/lib/python3.5/lib-dynload', '/home/erelsgl/.local/lib/python3.5/site-packages', '/usr/local/lib/python3.5/dist-packages', '/home/erelsgl/git/PrefLib-Tools/preflibtools', '/usr/local/lib/python3.5/dist-packages/xgboost-0.6-py3.5.egg', '/usr/local/lib/python3.5/dist-packages/dyNET-0.0.0-py3.5-linux-x86_64.egg', '/usr/lib/python3/dist-packages']

NOTE: recently I installed conda so I thought this might be the cause, but now I have removed it and the problem persists.


Solution

  • Looks like the compiled shared objects files are missing in your dynet installation. This may result from any mishap relating to installing or uninstalling of other programs. Your best bet is to try uninstalling and reinstalling dynet, and see if it works.

    If that does not work out try installing dynet in a virtual environment.