Python interface installation errors in Stanford CoreNLP

I am trying to build a python stanford NLP interface on Ubuntu 12.04.5 LTS. Two steps are required, the first of which:

  • compile Jpype by running "rake setup" in the 3rdParty / jpype file

In doing so, I get the following error:

In file included from src/native/common/jp_monitor.cpp:17:0: src/native/common/include/jpype.h:45:17: fatal error: jni.h: No such file or directory compilation terminated. error: command 'gcc' failed with exit status 1 rake aborted! Command failed with status (1): [cd JPype-0.5.4.1 && python setup.py build...] 

The error messages say that I am missing jni.h , so what is suggested here if I dpkg-query -L openjdk-7-jdk | grep "jni.h" dpkg-query -L openjdk-7-jdk | grep "jni.h" get /usr/lib/jvm/java-7-openjdk-amd64/include/jni.h .

I believe this means that I have jni.h on my system, so I am very confused right now. What causes the error? Can you suggest any fix?

Thanks for your help!


SEVERAL MORE STUDIES

Here is the instruction causing the error:

 gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/lib/jvm/java-1.5.0-sun-1.5.0.08/include -I/usr/lib/jvm/java-1.5.0-sun-1.5.0.08/include/linux -Isrc/native/common/include -Isrc/native/python/include -I/usr/include/python2.7 -c src/native/common/jp_class.cpp -o build/temp.linux-x86_64-2.7/src/native/common/jp_class.o cc1plus: warning: command line option '-Wstrict-prototypes' is valid for Ada/C/ObjC but not for C++ [enabled by default] In file included from src/native/common/jp_class.cpp:17:0:src/native/common/include/jpype.h:45:17: fatal error: jni.h: No such file or directory compilation terminated. error: command 'gcc' failed with exit status 1 

This comes from the JPype compilation needed for the python interface. I don't know why, but it includes paths that I don't have on my file system (i.e. -I/usr/lib/jvm/java-1.5.0-sun-1.5.0.08/include/linux ) .

How to configure these paths?

+5
source share
3 answers

This problem is a path problem (as stated in the question and @vikramls answered correctly).

Apparently, when you run the script to install the python interface for StanfordNLP, if JPype missing, it will be installed using the following command:

 python setup.py install 

Now, if you open the setup.py , you will see the following part, which sets the java paths for the Linux machine (I run on ubuntu):

 def setupLinux(self): self.javaHome = os.getenv("JAVA_HOME") if self.javaHome is None : self.javaHome = '/usr/lib/jvm/java-1.5.0-sun-1.5.0.08' # Ubuntu linux # self.javaHome = '/usr/java/jdk1.5.0_05' self.jdkInclude = "linux" self.libraries = ["dl"] self.libraryDir = [self.javaHome+"/lib"] 

Obviously, this path will not work on each machine, so there are two possible solutions:

  • Before starting the script installation, export a variable named JAVA_HOME with the location of your java installation. That is, export JAVA_HOME="/usr/lib/jvm/java-7-openjdk-amd64 in my case.

  • As this page says, you can set the auto-enable variable for gcc with the following export C_INCLUDE_PATH=some_path command export C_INCLUDE_PATH=some_path and this way should be installed in the place where the java libraries on your computer are located.

0
source

The indicated inclusion paths do not include the path where jni.h is located.

From your grep, jni.h is here: /usr/lib/jvm/java-7-openjdk-amd64/include/jni.h

Incoming paths specified in gcc arguments: -I/usr/lib/jvm/java-1.5.0-sun-1.5.0.08/include -I/usr/lib/jvm/java-1.5.0-sun-1.5.0.08/include/linux -Isrc/native/common/include -Isrc/native/python/include -I/usr/include/python2.7

Does it sound to me that you are building the wrong java? You have installed java-1.5.0 installation and java-7-openjdk - the java-7-openjdk file is missing in this file.

+2
source

Based on the following question, it seems that you can fix this by setting JAVA_HOME .

Problems compiling JPype

So, before using the building:

 export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64 
+2
source

Source: https://habr.com/ru/post/1206265/


All Articles