The project deployed online has been running normally for one year, and this morning suddenly reported FileNotFoundError: [Errno 2] No such file or directory:’/usr/lib/jvm’ error.
JPype is a tool that allows python code to easily call Java code, thus overcoming the shortcomings of python in some areas (such as server-side programming).
The actual operating environment of JPype is still the python runtime, but an embedded jvm is started during the runtime.
Cannot find jvm, probably because the environment variables are not in effect.
Usually you can run java directly on the command line because the bin directory where java is located is added to the PATH, and it takes effect as an environment variable after exporting PATH. But JAVA_HOME is only used as a common variable. When using os.getenv() to get environment variables, JAVA_HOME cannot be found, so it is speculated that you should just add export in front of JAVA_HOME and restart the project.
Solution:
Add export JAVA_HOME to the global configuration file /etc/profile or personal configuration file ~/.bashrc or ~/.bash_profile. The following is the setting of my /etc/profile:
# set java path export JAVA_HOME =/usr/local/java/ latest export PATH =${JAVA_HOME}/ bin:${PATH} export CLASSPATH =.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/ tools.jar Other notes: If you use PyCharm remote debugging, if you encounter the same error, you need to set the environment variables before importing pyhanlp, as follows # Set environment variables import os os.environ[ ' JAVA_HOME ' ] = ' /usr/local/java/latest ' # Import JPype again to avoid the problem of not being able to find java import jpype
end!
Similar Posts:
- HDFS Operate hadoop Error: Command not Found [How to Solve]
- [Solved] NB: JAVA_HOME should point to a JDK not a JRE
- JAVA Command Error: A JNI error has occurred, please check your installation and try again [Solved]
- [Solved] Mac install maven Error: zsh: command not found: MVN
- Mac ADB prompts command not found
- Linux use the man command error: Man: command not found [How to Solve]
- Solve the problem of ADB: command not found on MAC
- [Solved] JSCH cannot run JAVA bash:java:Command not found.
- [Solved] JAVA Run Error: Error: Could not find or load main class
- CentOS Error -bash:systemctl:command not found