zhijing-jin / bleu

A Handy Python wrapper for common NLP evaluation scripts like BLEU.
BSD 3-Clause "New" or "Revised" License
14 stars 2 forks source link

ConnectionRefusedError: [Errno 111] Connection refused #3

Open RyanLiut opened 4 years ago

RyanLiut commented 4 years ago

After installing the blue successfully, when I type the command "from bleu import list_bleu" it said Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/disk2/liuzhu/anaconda3/lib/python3.7/site-packages/bleu/__init__.py", line 8, in <module> from .bleu import file_bleu, multi_file_bleu, list_bleu, multi_list_bleu, \ File "/disk2/liuzhu/anaconda3/lib/python3.7/site-packages/bleu/bleu.py", line 16, in <module> from .download import TMP_DIR, DETOK_FILE, BLEU_DETOK_FILE, BLEU_FILE File "/disk2/liuzhu/anaconda3/lib/python3.7/site-packages/bleu/download.py", line 28, in <module> DETOK_FILE, BLEU_DETOK_FILE, BLEU_FILE = download_scripts(TMP_DIR) File "/disk2/liuzhu/anaconda3/lib/python3.7/site-packages/bleu/download.py", line 21, in download_scripts urlretrieve(url, fname) File "/disk2/liuzhu/anaconda3/lib/python3.7/urllib/request.py", line 247, in urlretrieve with contextlib.closing(urlopen(url, data)) as fp: File "/disk2/liuzhu/anaconda3/lib/python3.7/urllib/request.py", line 222, in urlopen return opener.open(url, data, timeout) File "/disk2/liuzhu/anaconda3/lib/python3.7/urllib/request.py", line 525, in open response = self._open(req, data) File "/disk2/liuzhu/anaconda3/lib/python3.7/urllib/request.py", line 543, in _open '_open', req) File "/disk2/liuzhu/anaconda3/lib/python3.7/urllib/request.py", line 503, in _call_chain result = func(*args) File "/disk2/liuzhu/anaconda3/lib/python3.7/urllib/request.py", line 1360, in https_open context=self._context, check_hostname=self._check_hostname) File "/disk2/liuzhu/anaconda3/lib/python3.7/urllib/request.py", line 1319, in do_open raise URLError(err) urllib.error.URLError: <urlopen error [Errno 111] Connection refused> How to solve it?

rosefun commented 3 years ago

Same problem.

import bleu File "E:\SoftwareInstall\anaconda3.5.2.0\lib\site-packages\bleu\__init__.py", line 8, in <module> from .bleu import file_bleu, multi_file_bleu, list_bleu, multi_list_bleu, \ File "E:\SoftwareInstall\anaconda3.5.2.0\lib\site-packages\bleu\bleu.py", line 16, in <module> from .download import TMP_DIR, DETOK_FILE, BLEU_DETOK_FILE, BLEU_FILE File "E:\SoftwareInstall\anaconda3.5.2.0\lib\site-packages\bleu\download.py", line 28, in <module> DETOK_FILE, BLEU_DETOK_FILE, BLEU_FILE = download_scripts(TMP_DIR) File "E:\SoftwareInstall\anaconda3.5.2.0\lib\site-packages\bleu\download.py", line 21, in download_scripts urlretrieve(url, fname) File "E:\SoftwareInstall\anaconda3.5.2.0\lib\urllib\request.py", line 248, in urlretrieve with contextlib.closing(urlopen(url, data)) as fp: File "E:\SoftwareInstall\anaconda3.5.2.0\lib\urllib\request.py", line 223, in urlopen return opener.open(url, data, timeout) File "E:\SoftwareInstall\anaconda3.5.2.0\lib\urllib\request.py", line 526, in open response = self._open(req, data) File "E:\SoftwareInstall\anaconda3.5.2.0\lib\urllib\request.py", line 544, in _open '_open', req) File "E:\SoftwareInstall\anaconda3.5.2.0\lib\urllib\request.py", line 504, in _call_chain result = func(*args) File "E:\SoftwareInstall\anaconda3.5.2.0\lib\urllib\request.py", line 1361, in https_open context=self._context, check_hostname=self._check_hostname) File "E:\SoftwareInstall\anaconda3.5.2.0\lib\urllib\request.py", line 1320, in do_open raise URLError(err) urllib.error.URLError: <urlopen error [WinError 10054] 远程主机强迫关闭了一个现有的连接。>

zhijing-jin commented 3 years ago

Hi all, thanks for the post.

This error should be related to download.py - https://github.com/zhijing-jin/bleu/blob/a129eb67ec844cdbf0e6c7bc0ab8a611b07ef667/bleu/download.py#L8-L13

From your error message, it seems that it is not able to download the three files using urlretrieve:

A possible fix can be

  1. Check if urlretrieve works properly on your end: from urllib.request import urlretrieve; urlretrieve(url, fname)
  2. Check if you can access the above websites (via a browser, etc)
  3. Run the code again.
  4. Alternative to 1-3, you can directly download the three files and put them in TMP_DIR of download.py