brendano / stanford_corenlp_pywrapper

151 stars 59 forks source link

Server class not found #19

Closed salsaman closed 9 years ago

salsaman commented 9 years ago

Hi, I followed the instructions in the README. When trying to run the test from python I get:

Error: Could not find or load main class corenlp.SocketServer

brendano commented 9 years ago

what OS? i just did a clean checkout and it worked.

(we only support mac and linux.)

salsaman commented 9 years ago

Ubuntu 14.04

salsaman commented 9 years ago

I ran "sudo pip install .", it seemed to go fine, no errors. I see some files in /usr/local/lib/python2.7/dist-packages/

drwxr-sr-x 3 root staff 4096 May 19 11:25 stanford_corenlp_pywrapper drwxr-sr-x 2 root staff 4096 May 19 11:25 stanford_corenlp_pywrapper-0.1.0.egg-info

In the former, I have: -rw-rw-r-- 1 root staff 1891110 May 15 19:11 guava-13.0.1.jar -rw-rw-r-- 1 root staff 1125973 May 15 19:11 jackson-all-1.9.11.jar

I also have in Downloads: stanford_corenlp_pywrapper-master/stanford_corenlp_pywrapper/javasrc/corenlp/SocketServer.java

so it looks like it is not getting compiled.

brendano commented 9 years ago

ok it's a problem with how pip install works with our code. it can't find the jar file. sockwrap.py expects corenlpwrapper.jar to be in a directory called "lib" in the same dir as sockwrap.py, like it's laid out in the source directories. let us know if you figure out the problem. i actually dont use this software with pip myself, but i was under the impression other people do.

brendano commented 9 years ago

also print out the java command too. i recently switched it to using wildcards on the classpath, which supposedly java knows how to deal with.

salsaman commented 9 years ago

Sorry I can't find the file corenlpwrapper.jar anywhere.

I tried copying the .java files from stanford_corenlp_pywrapper/javasrc/corenlp/ into /usr/local/lib/python2.7/dist-packages/stanford_corenlp_pywrapper/lib and also to /usr/local/lib/python2.7/dist-packages/stanford_corenlp_pywrapper/lib/corenlp, neither of these worked. I also tried copying the .java files into my main stanford nlp directory but this did not work either.

Can you be a bit more specific about which files need to be copied where ?

The java line which is being run seems OK:

INFO:StanfordSocketWrap:Starting pipe subprocess, and waiting for signal it's ready, with command: exec java -Xmx4g -XX:ParallelGCThreads=1 -cp '/home/gf/Downloads/stanford_corenlp_pywrapper-master/stanford_corenlppywrapper/lib/:/home/gf/Downloads/stanford-corenlp-full-2014-10-26/_' corenlp.SocketServer --server 12340 --configdict '{"annotators": "tokenize, ssplit, pos, lemma"}' Error: Could not find or load main class corenlp.SocketServer

brendano commented 9 years ago

it's very simple. all you need to do is use the stanford_corenlp_pywrapper subdirectory. if the whole thing is correctly copied over, everything should work fine.

the .java files dont matter. the python code uses precompiled jars.

please uninstall and reinstall and recursively list the files in the installed directory: find /usr/local/lib/python2.7/dist-packages/stanford_corenlp_pywrapper

this will help us diagnose what's going on.

the jar files are in the lib/ directory. that directory is supposed to get copied to wherever you're using it.

brendano commented 9 years ago

btw that line of java code is NOT using the pip installed version! it's in your download dir. but that should work fine.

salsaman commented 9 years ago

OK, so I did:

$ cd stanford_corenlp_pywrapper-master $ sudo pip uninstall . $ sudo pip install .

Unpacking /home/gf/Downloads/stanford_corenlp_pywrapper-master Running setup.py (path:/tmp/pip-ghfEZ4-build/setup.py) egg_info for package from file:///home/gf/Downloads/stanford_corenlp_pywrapper-master

Installing collected packages: stanford-corenlp-pywrapper Running setup.py install for stanford-corenlp-pywrapper

Successfully installed stanford-corenlp-pywrapper Cleaning up...

$ ls -l /usr/local/lib/python2.7/dist-packages/stanford_corenlp_pywrapper* /usr/local/lib/python2.7/dist-packages/stanford_corenlp_pywrapper: total 52 -rw-r--r-- 1 root staff 0 May 15 19:11 init.py -rw-r--r-- 1 root staff 164 May 19 13:07 init.pyc drwxr-sr-x 2 root staff 4096 May 19 13:07 lib -rw-r--r-- 1 root staff 7505 May 19 11:17 pipewrap.py -rw-r--r-- 1 root staff 9779 May 19 13:07 pipewrap.pyc -rw-r--r-- 1 root staff 10821 May 15 19:11 sockwrap.py -rw-r--r-- 1 root staff 11765 May 19 13:07 sockwrap.pyc

/usr/local/lib/python2.7/dist-packages/stanford_corenlp_pywrapper-0.1.0.egg-info: total 20 -rw-r--r-- 1 root staff 1 May 19 13:07 dependency_links.txt -rw-r--r-- 1 root staff 422 May 19 13:07 installed-files.txt -rw-r--r-- 1 root staff 222 May 19 13:07 PKG-INFO -rw-r--r-- 1 root staff 418 May 19 13:07 SOURCES.txt -rw-r--r-- 1 root staff 27 May 19 13:07 top_level.txt

Still the same error.

brendano commented 9 years ago

please do a recursive listing. you listed the lib/ directory but not what is in it! that's the most important one for this problem! :)

On Tue, May 19, 2015 at 12:12 PM, salsaman notifications@github.com wrote:

OK, so I did:

$ cd stanford_corenlp_pywrapper-master $ sudo pip uninstall . $ sudo pip install .

Unpacking /home/gf/Downloads/stanford_corenlp_pywrapper-master Running setup.py (path:/tmp/pip-ghfEZ4-build/setup.py) egg_info for package from file:///home/gf/Downloads/stanford_corenlp_pywrapper-master

Installing collected packages: stanford-corenlp-pywrapper Running setup.py install for stanford-corenlp-pywrapper

Successfully installed stanford-corenlp-pywrapper Cleaning up...

$ ls -l /usr/local/lib/python2.7/dist-packages/stanford_corenlp_pywrapper* /usr/local/lib/python2.7/dist-packages/stanford_corenlp_pywrapper: total 52 -rw-r--r-- 1 root staff 0 May 15 19:11 init.py -rw-r--r-- 1 root staff 164 May 19 13:07 init.pyc drwxr-sr-x 2 root staff 4096 May 19 13:07 lib -rw-r--r-- 1 root staff 7505 May 19 11:17 pipewrap.py -rw-r--r-- 1 root staff 9779 May 19 13:07 pipewrap.pyc -rw-r--r-- 1 root staff 10821 May 15 19:11 sockwrap.py -rw-r--r-- 1 root staff 11765 May 19 13:07 sockwrap.pyc

/usr/local/lib/python2.7/dist-packages/stanford_corenlp_pywrapper-0.1.0.egg-info: total 20 -rw-r--r-- 1 root staff 1 May 19 13:07 dependency_links.txt -rw-r--r-- 1 root staff 422 May 19 13:07 installed-files.txt -rw-r--r-- 1 root staff 222 May 19 13:07 PKG-INFO -rw-r--r-- 1 root staff 418 May 19 13:07 SOURCES.txt -rw-r--r-- 1 root staff 27 May 19 13:07 top_level.txt

Still the same error.

— Reply to this email directly or view it on GitHub https://github.com/brendano/stanford_corenlp_pywrapper/issues/19#issuecomment-103570405 .

salsaman commented 9 years ago

These are the contents, same as before:

$ ls -lr /usr/local/lib/python2.7/dist-packages/stanford_corenlp_pywrapper/lib/ total 2948 -rw-rw-r-- 1 root staff 1125973 May 15 19:11 jackson-all-1.9.11.jar -rw-rw-r-- 1 root staff 1891110 May 15 19:11 guava-13.0.1.jar

salsaman commented 9 years ago

I am wondering if I should be running build.sh ? I tried this a couple of times, the first time it gave an error about not finding zsh. I changed this to bash, and then it worked but with many errors, eg.

++ dirname ./build.sh

etc..

salsaman commented 9 years ago

I see there is /home/sw hardcoded there in CORENLP_JAR

brendano commented 9 years ago

forget the build. you should have the prebuilt jar in your git checkout. it's in the repo right now. something is bizarre here. tell you what, forget the pip installation and just try to use it locally first. sorry but this is very difficult for me to remotely debug

On Tue, May 19, 2015 at 12:23 PM, salsaman notifications@github.com wrote:

I see there is /home/sw hardcoded there in CORENLP_JAR

— Reply to this email directly or view it on GitHub https://github.com/brendano/stanford_corenlp_pywrapper/issues/19#issuecomment-103578073 .

salsaman commented 9 years ago

Maybe the problem is that I downloaded the zip rather than did a checkout ? Let me try with git checkout.

salsaman commented 9 years ago

Odd. The jar file is there when I do a git clone, but it is missing from the .zip file. Let me check if it works now.

salsaman commented 9 years ago

OK it works now ! Thanks for your help !

brendano commented 9 years ago

that's bizarre. i just downloaded the zip and it was there.

salsaman commented 9 years ago

Yes it is bizarre. I just checked the .zip and unzipped it again. The file is there... Somehow the first time I did the unzip the file must have gotten deleted or something, I don't quite know what happened there.

Thanks again for your help. I can confirm it is all working now.