stanfordnlp / stanza

Stanford NLP Python library for tokenization, sentence segmentation, NER, and parsing of many human languages
https://stanfordnlp.github.io/stanza/
Other
7.25k stars 888 forks source link

unable to start the CoreNLP server #1392

Open fang196 opened 4 months ago

fang196 commented 4 months ago

Describe the bug I went down the issue when running this demo.

To Reproduce Run the following code:

# Import client module
from stanza.server import CoreNLPClient
# Construct a CoreNLPClient with some basic annotators, a memory allocation of 4GB, and port number 9001
client = CoreNLPClient(
    annotators=['tokenize','ssplit', 'pos', 'lemma', 'ner'], 
    memory='4G', 
    endpoint='http://localhost:9000',
    be_quiet=False)
print(client)

# Start the background server and wait for some time
# Note that in practice this is totally optional, as by default the server will be started when the first annotation is performed
client.start()
import time; time.sleep(10)

Error message:

2024-05-10 16:41:27 INFO: Writing properties to tmp file: corenlp_server-1c2c0b7050454efc.props
<stanza.server.client.CoreNLPClient object at 0x7fab78e1e4c0>
---------------------------------------------------------------------------
OSError                                   Traceback (most recent call last)
File ~/miniconda3/envs/instblip-peft/lib/python3.8/site-packages/stanza/server/client.py:134, in RobustService.start(self)
    [133](https://vscode-remote+ssh-002dremote-002ba100-00282-0029.vscode-resource.vscode-cdn.net/home/qxy/AD%2BLLMs/scienceqa/CoT/Graph-of-Thought/~/miniconda3/envs/instblip-peft/lib/python3.8/site-packages/stanza/server/client.py:133) try:
--> [134](https://vscode-remote+ssh-002dremote-002ba100-00282-0029.vscode-resource.vscode-cdn.net/home/qxy/AD%2BLLMs/scienceqa/CoT/Graph-of-Thought/~/miniconda3/envs/instblip-peft/lib/python3.8/site-packages/stanza/server/client.py:134)     sock.bind((self.host, self.port))
    [135](https://vscode-remote+ssh-002dremote-002ba100-00282-0029.vscode-resource.vscode-cdn.net/home/qxy/AD%2BLLMs/scienceqa/CoT/Graph-of-Thought/~/miniconda3/envs/instblip-peft/lib/python3.8/site-packages/stanza/server/client.py:135) except socket.error as e:

OSError: [Errno 98] Address already in use

The above exception was the direct cause of the following exception:

PermanentlyFailedException                Traceback (most recent call last)
Cell In[12], [line 11](vscode-notebook-cell:?execution_count=12&line=11)
      [7](vscode-notebook-cell:?execution_count=12&line=7) print(client)
      [9](vscode-notebook-cell:?execution_count=12&line=9) # Start the background server and wait for some time
     [10](vscode-notebook-cell:?execution_count=12&line=10) # Note that in practice this is totally optional, as by default the server will be started when the first annotation is performed
---> [11](vscode-notebook-cell:?execution_count=12&line=11) client.start()
     [12](vscode-notebook-cell:?execution_count=12&line=12) import time; time.sleep(10)

File ~/miniconda3/envs/instblip-peft/lib/python3.8/site-packages/stanza/server/client.py:141, in RobustService.start(self)
    [139](https://vscode-remote+ssh-002dremote-002ba100-00282-0029.vscode-resource.vscode-cdn.net/home/qxy/AD%2BLLMs/scienceqa/CoT/Graph-of-Thought/~/miniconda3/envs/instblip-peft/lib/python3.8/site-packages/stanza/server/client.py:139)                 return
    [140](https://vscode-remote+ssh-002dremote-002ba100-00282-0029.vscode-resource.vscode-cdn.net/home/qxy/AD%2BLLMs/scienceqa/CoT/Graph-of-Thought/~/miniconda3/envs/instblip-peft/lib/python3.8/site-packages/stanza/server/client.py:140)             else:
--> [141](https://vscode-remote+ssh-002dremote-002ba100-00282-0029.vscode-resource.vscode-cdn.net/home/qxy/AD%2BLLMs/scienceqa/CoT/Graph-of-Thought/~/miniconda3/envs/instblip-peft/lib/python3.8/site-packages/stanza/server/client.py:141)                 raise PermanentlyFailedException("Error: unable to start the CoreNLP server on port %d "
    [142](https://vscode-remote+ssh-002dremote-002ba100-00282-0029.vscode-resource.vscode-cdn.net/home/qxy/AD%2BLLMs/scienceqa/CoT/Graph-of-Thought/~/miniconda3/envs/instblip-peft/lib/python3.8/site-packages/stanza/server/client.py:142)                                                  "(possibly something is already running there)" % self.port) from e
    [143](https://vscode-remote+ssh-002dremote-002ba100-00282-0029.vscode-resource.vscode-cdn.net/home/qxy/AD%2BLLMs/scienceqa/CoT/Graph-of-Thought/~/miniconda3/envs/instblip-peft/lib/python3.8/site-packages/stanza/server/client.py:143) if self.be_quiet:
    [144](https://vscode-remote+ssh-002dremote-002ba100-00282-0029.vscode-resource.vscode-cdn.net/home/qxy/AD%2BLLMs/scienceqa/CoT/Graph-of-Thought/~/miniconda3/envs/instblip-peft/lib/python3.8/site-packages/stanza/server/client.py:144)     # Issue #26: subprocess.DEVNULL isn't supported in python 2.7.
    [145](https://vscode-remote+ssh-002dremote-002ba100-00282-0029.vscode-resource.vscode-cdn.net/home/qxy/AD%2BLLMs/scienceqa/CoT/Graph-of-Thought/~/miniconda3/envs/instblip-peft/lib/python3.8/site-packages/stanza/server/client.py:145)     if hasattr(subprocess, 'DEVNULL'):

PermanentlyFailedException: Error: unable to start the CoreNLP server on port 9000 (possibly something is already running there)

Environment (please complete the following information):

Additional context I've tried netstat -anpe | grep "9000" | grep "LISTEN" and it returned tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 1000 918534305 -. However, other ports that don't have anything running also encountered the same problem.

ps -o pid,cmd | grep java shows no result either.

Please provide more solutions.

AngledLuffa commented 4 months ago

According to the error, there is already something running on 9000

On Fri, May 10, 2024, 1:53 AM fang196 @.***> wrote:

Describe the bug I went down the issue when running this demo https://github.com/stanfordnlp/stanza/blob/main/demo/Stanza_CoreNLP_Interface.ipynb .

To Reproduce Run the following code:

Import client module

from stanza.server import CoreNLPClient

Construct a CoreNLPClient with some basic annotators, a memory allocation of 4GB, and port number 9001

client = CoreNLPClient( annotators=['tokenize','ssplit', 'pos', 'lemma', 'ner'], memory='4G', endpoint='http://localhost:9000', be_quiet=False) print(client)

Start the background server and wait for some time

Note that in practice this is totally optional, as by default the server will be started when the first annotation is performed

client.start() import time; time.sleep(10)

Error message:

2024-05-10 16:41:27 INFO: Writing properties to tmp file: corenlp_server-1c2c0b7050454efc.props <stanza.server.client.CoreNLPClient object at 0x7fab78e1e4c0>

OSError Traceback (most recent call last) File ~/miniconda3/envs/instblip-peft/lib/python3.8/site-packages/stanza/server/client.py:134, in RobustService.start(self) 133 try: --> 134 sock.bind((self.host, self.port)) 135 except socket.error as e:

OSError: [Errno 98] Address already in use

The above exception was the direct cause of the following exception:

PermanentlyFailedException Traceback (most recent call last) Cell In[12], line 11 7 print(client) 9 # Start the background server and wait for some time 10 # Note that in practice this is totally optional, as by default the server will be started when the first annotation is performed ---> 11 client.start() 12 import time; time.sleep(10)

File ~/miniconda3/envs/instblip-peft/lib/python3.8/site-packages/stanza/server/client.py:141, in RobustService.start(self) 139 return 140 else: --> 141 raise PermanentlyFailedException("Error: unable to start the CoreNLP server on port %d " 142 "(possibly something is already running there)" % self.port) from e 143 if self.be_quiet: 144 # Issue #26: subprocess.DEVNULL isn't supported in python 2.7. 145 if hasattr(subprocess, 'DEVNULL'):

PermanentlyFailedException: Error: unable to start the CoreNLP server on port 9000 (possibly something is already running there)

Environment (please complete the following information):

  • OS: Ubuntu20.8
  • Python version: Python 3.8.18 from Anaconda
  • Stanza version: 1.8.2

Additional context I've tried netstat -anpe | grep "9000" | grep "LISTEN" and it returned tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 1000 918534305 -. However, other ports that don't have anything running also encountered the same problem.

ps -o pid,cmd | grep java shows no result either.

Please provide more solutions.

— Reply to this email directly, view it on GitHub https://github.com/stanfordnlp/stanza/issues/1392, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA2AYWJLM74MTBNUY45ZQDDZBSDJ5AVCNFSM6AAAAABHQIANGCVHI2DSMVQWIX3LMV43ASLTON2WKOZSGI4DSMZQGMYDCNQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>