You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

下载NLTK停用词时遇Errno 110连接超时错误求助

解决NLTK下载stopwords超时问题

方法1:手动下载停用词包

  • 找到NLTK官方的stopwords数据集压缩包,下载后解压。
  • 运行以下命令查看NLTK的数据存储路径:
    import nltk
    print(nltk.data.path)
    
  • 选择其中一个路径,在该路径下创建corpora文件夹(如果不存在),将解压后的stopwords文件夹放入corpora目录中。

方法2:使用国内镜像源加速下载

代码方式:

import nltk
# 可自定义download_dir,不指定则用默认路径
nltk.download('stopwords', mirror='https://mirrors.tuna.tsinghua.edu.cn/nltk_data/')

命令行方式:

python -m nltk.downloader --mirror https://mirrors.tuna.tsinghua.edu.cn/nltk_data/ stopwords

方法3:配置网络代理(若处于代理环境)

代码方式:

import os
# 替换为你的代理地址和端口
os.environ['http_proxy'] = 'http://proxy_address:port'
os.environ['https_proxy'] = 'https://proxy_address:port'

import nltk
nltk.download('stopwords')

命令行方式:

  • Linux/macOS:
    export http_proxy=http://proxy_address:port
    export https_proxy=https://proxy_address:port
    python -m nltk.downloader stopwords
    
  • Windows:
    set http_proxy=http://proxy_address:port
    set https_proxy=https://proxy_address:port
    python -m nltk.downloader stopwords
    

内容的提问来源于stack exchange,提问作者Saurabh Sharma

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.07 21:20:28