from nltk.parse.corenlp import CoreNLPServer
server = CoreNLPServer()
server.start()
运行上面的代码时,出现以下错误。
Traceback (most recent call last):
File "server.py", line 30, in <module>
server.start()
File "/usr/local/lib/python2.7/dist-packages/nltk/parse/corenlp.py", line 130, in start
stderr=stderr,
File "/usr/local/lib/python2.7/dist-packages/nltk/internals.py", line 112, in java
subprocess_output_dict = {'pipe': subprocess.PIPE, 'stdout': subprocess.STDOUT, 'devnull': subprocess.DEVNULL}
AttributeError: 'module' object has no attribute 'DEVNULL'
答案 0 :(得分:1)
subprocess.devnull
是Python 3.3的新功能。
确保使用nltk
版本,该版本仍支持Python 2.7。来自their changelog:
Version 3.5 2019-10-16
* drop support for Python 2