2

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.

Munim Munna
  • 17,178
  • 6
  • 29
  • 58
Erel Segal-Halevi
  • 33,955
  • 36
  • 114
  • 183
  • Please check your python3 version. Is it 3.5? It is very unlikely that it is different, but import error despite installed library is also unlikely. Further, can you post the value of ``sys.path``. – MS_ Jan 31 '19 at 04:27
  • @MS_ I added this to the question. After looking at the output, it seems the problem is related to conda (I did not have the problem before installing conda). What can I do - is it possible to work with both pip and conda at the same time? – Erel Segal-Halevi Jan 31 '19 at 06:13
  • Alternatively, can I remove conda such that my system will come back to what it was before? – Erel Segal-Halevi Jan 31 '19 at 06:24
  • 1
    Your python3 in terminal is v3.7, has no dynet installed and python in pycharm is v3.5 which has dynet. So when you run from terminal, you get no module error. Try uninstalling and installing dynet from pycharm console. – Munim Munna Jan 31 '19 at 21:18
  • @MunimMunna I removed conda and the problem persists... any other ideas? – Erel Segal-Halevi Feb 07 '19 at 12:59

1 Answers1

2

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.

Munim Munna
  • 17,178
  • 6
  • 29
  • 58