py4j.protocol.Py4JNetworkError:尝试连接到Java服务器时发生错误

时间:2015-09-18 02:53:39

标签: python-2.7 nltk py4j

我试图理解这个使用Py4j的代码。但是,每次运行代码时,我都会遇到相同的错误。我在我的Ubuntu 14.04中安装了py4j。 jar文件位于usr / share / py4j中。

代码是

from nltk.tokenize.punkt import PunktSentenceTokenizer, PunktParameters
from nltk.tokenize import wordpunct_tokenize , sent_tokenize
from py4j.java_gateway import JavaGateway
import nltk
from nltk.tree import Tree
import os.path
import parsers

LangPaths =os.path.realpath("/home/Downloads/Abstractive Summarizer/SumMe-master/Summarizer/langdetector/profiles/")
tltagger = nltk.data.load("taggers/english.pickle")
tlChunker = nltk.data.load("chunkers/maxent_ne_chunker/english_ace_binary.pickle")
enChunker = nltk.data.load("chunkers/maxent_ne_chunker/english_ace_multiclass.pickle")
punkt_param  = PunktParameters()  #creates an opening for tokenizer parameters.
punkt_param.abbrev_types = set(['gng','mr','mrs','dr','rep']) #abbreviations further accepted goes here
sentence_splitter = PunktSentenceTokenizer(punkt_param)
tokenized = ""
gateway = JavaGateway()
detector = gateway.entry_point
detector.init(LangPaths)

我得到的错误是

  

文件" / home / shiju / Downloads / Abstractive   Summarizer / SumMe-master / Summarizer / preprocessor.py",第29行,in          detector.init(LangPaths)

     

File" /usr/local/lib/python2.7/dist-packages/py4j/java_gateway.py",   第811行,在__call_ answer =中   self.gateway_client.send_command(命令)`

     

File" /usr/local/lib/python2.7/dist-packages/py4j/java_gateway.py",   第624行,在send_command中       connection = self._get_connection()

     

File" /usr/local/lib/python2.7/dist-packages/py4j/java_gateway.py",   第579行,在_get_connection中       connection = self._create_connection()File" /usr/local/lib/python2.7/dist-packages/py4j/java_gateway.py" ;, line   585,在_create_connection中       connection.start()

     

File" /usr/local/lib/python2.7/dist-packages/py4j/java_gateway.py",   第697行,开始       引发Py4JNetworkError(msg,e)py4j.protocol.Py4JNetworkError:尝试连接Java服务器时发生错误

我认为Python无法与Java应用程序连接

0 个答案:

没有答案
相关问题