gpt4 book ai didi

python - 下载 NLTK 语料库时出现 ElementTree.ParseError

转载 作者:太空宇宙 更新时间:2023-11-03 15:59:38 35 4
gpt4 key购买 nike

我已经在我的 CentOS 计算机上安装了 nltk 3.2.1
现在,每当我尝试下载 NLTK 的任何语料库/模型时,都会出现以下错误:

Traceback (most recent call last):
File "/usr/lib64/python2.7/runpy.py", line 162, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "/usr/lib64/python2.7/runpy.py", line 72, in _run_code
exec code in run_globals
File "/usr/lib/python2.7/site-packages/nltk/downloader.py", line 2268, in <module>
halt_on_error=options.halt_on_error)
File "/usr/lib/python2.7/site-packages/nltk/downloader.py", line 664, in download
for msg in self.incr_download(info_or_id, download_dir, force):
File "/usr/lib/python2.7/site-packages/nltk/downloader.py", line 534, in incr_download
try: info = self._info_or_id(info_or_id)
File "/usr/lib/python2.7/site-packages/nltk/downloader.py", line 508, in _info_or_id
return self.info(info_or_id)
File "/usr/lib/python2.7/site-packages/nltk/downloader.py", line 875, in info
self._update_index()
File "/usr/lib/python2.7/site-packages/nltk/downloader.py", line 825, in _update_index
ElementTree.parse(compat.urlopen(self._url)).getroot())
File "/usr/lib64/python2.7/xml/etree/ElementTree.py", line 1182, in parse
tree.parse(source, parser)
File "/usr/lib64/python2.7/xml/etree/ElementTree.py", line 656, in parse
parser.feed(data)
File "/usr/lib64/python2.7/xml/etree/ElementTree.py", line 1642, in feed
self._raiseerror(v)
File "/usr/lib64/python2.7/xml/etree/ElementTree.py", line 1506, in _raiseerror
raise err
xml.etree.ElementTree.ParseError: syntax error: line 1, column 49

请注意,我已尝试了以下所有方法来下载 NLTK 数据 -

  • nltk.download()
  • nltk.download('全部')
  • python -m nltk.downloader all

但是在所有方法中我都收到相同的错误。
有人知道我为什么会收到此错误以及如何下载 NLTK 数据吗?
任何帮助,将不胜感激!

最佳答案

让我们看看:您的下载程序打开列出可用下载的 xml 文档,尝试解析它,并收到错误:

ElementTree.parse(compat.urlopen(self._url)).getroot())

要么(非常不可能)nltk 站点不再与 Python 2.7 兼容,要么您实际上没有收到预期的 XML 文档,因为您的连接有问题。你是behind a proxy?如果没有,您的连接可能有其他问题。

关于python - 下载 NLTK 语料库时出现 ElementTree.ParseError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40458145/

35 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com