google / sling

SLING - A natural language frame semantics parser
Apache License 2.0
1.93k stars 268 forks source link

ImportError: No module named 'sling.pysling' #422

Closed FlorianPfisterer closed 5 years ago

FlorianPfisterer commented 5 years ago

System

I have cloned the sling repository (master branch), run the setup.sh script (which was successful) and then started a python3 session. When I type import sling it throws the following error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3/dist-packages/sling/__init__.py", line 1, in <module>
    import sling.pysling as api
ImportError: No module named 'sling.pysling'

The same error occurs when I run the training script (sling/nlp/parser/tools/train.sh), which I have modified to use python3 instead of python (just replace the Python command in the second to last line):

Traceback (most recent call last):
  File "sling/nlp/parser/tools/train_pytorch.py", line 18, in <module>
    import sling
  File "/usr/lib/python3/dist-packages/sling/__init__.py", line 1, in <module>
    import sling.pysling as api
ImportError: No module named 'sling.pysling'
Done. Log is available at test_train_1/log.

What am I doing wrong?

ringgaard commented 5 years ago

It looks like you did it the right way, but something went wrong. My guess is that pysling.so file is missing in the python directory.

The setup.sh script will create a symbolic link from /usr/lib/python3/dist-packages/sling to the python subdirectory in your repo directory (unless this directory already exists), e.g.:

$ ls -l /usr/lib/python3/dist-packages/sling
lrwxrwxrwx 1 root root 28 May  7 15:51 /usr/lib/python3/dist-packages/sling -> /home/$USER/sling/python

The python subdirectory then contains a symbolic link to pysling.so:

$ ls -l /home/$USER/sling/python/
lrwxrwxrwx 1 michael staff    35 Jan  4  2018 pysling.so -> ../bazel-bin/sling/pyapi/pysling.so

Can I get you to check that this chain of symbolic links are properly installed on your machine?

PS: I will get the python->python3 bug fixed in the training script.

FlorianPfisterer commented 5 years ago

Thanks for the fast reply! I investigated sling/python/pysling.so more and this led me to the problem: The setup.sh script was actually not the problem. I noticed that when transferring the sling folder via FTP to the remote machine, sling/python/pysling.so could not be transferred for some reason. When cloning the repository from GitHub to the remote machine directly, it worked.

ringgaard commented 5 years ago

Sounds good. As mentioned, the repo has a few symbolic links, and these can probably not be copied using FTP.