在 NLTK 中下载“punkt”时出现 WinError 10060 连接超时错误

问题描述 投票:0回答:1

我在 Python 中遇到了 NLTK 库的问题,特别是在尝试下载“punkt”标记生成器模型时。这是我收到的错误消息:

背景: 我正在尝试使用以下代码下载

punkt
包:

import nltk
nltk.download('punkt')

Troubleshooting Steps I've Taken:

Checked my internet connection, which seems to be working fine.
Temporarily disabled firewall and antivirus software, but the issue persists.
Attempted to use a different internet connection (e.g., mobile hotspot), but faced the same error.
python jupyter-notebook nltk
1个回答
0
投票

尝试使用以下代码:

导入nltk 导入操作系统

nltk.download('punkt', download_dir=os.getcwd(),安静=True)

这对我有用。

© www.soinside.com 2019 - 2024. All rights reserved.