stanfordcorenlp报错: RuntimeError: Java not found.

stanfordcorenlp报错:

RuntimeError: Java not found.

 

具体如下所示:

Traceback (most recent call last):
  File "D:\Users\user\AppData\Local\Anaconda3\lib\site-packages\IPython\core\interactiveshell.py", line 2881, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "", line 1, in
    nlp = StanfordCoreNLP(r'D:\\Users\\tongtong_liu\\PJCode\\gstrip_extractDistrictAndPOI\\stanford_nlp\\stanford-corenlp-4.0.0', lang='en')
  File "D:\Users\user\AppData\Local\Anaconda3\lib\site-packages\stanfordcorenlp\corenlp.py", line 47, in __init__
    raise RuntimeError('Java not found.')
RuntimeError: Java not found.

 

原因:

之前安装了jdk1.7,又重新安装了jdk1.8导致文件冲突

 

解决方案:

删除C:\Windows\System32 下的java.exe、javaw.exe和javaws.exe

 

思路:

查看StanfordCoreNLP的源码

单独运行subprocess.call(['java', '-version'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)

其返回值为2

单独运行subprocess.call(['java', '-version']  发现是因为java的版本问题

 


 

再google如何解决java版本问题

 

 

参考资料:

https://blog.csdn.net/LANGZI7758521/article/details/81196176

https://blog.csdn.net/zhaoxiangjun_/article/details/84584102

https://blog.csdn.net/weinichendian/article/details/78559496

 

 

 

 

 

你可能感兴趣的:(stanfordcorenlp报错: RuntimeError: Java not found.)