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

macOS本地Jupyter Notebook中nltk.download('stopwords') SSL证书验证失败求助

macOS下Jupyter Notebook中NLTK下载SSL证书错误的解决办法

方法一:临时绕过SSL验证(快速解决)

直接在nltk.download()中添加ssl_verify=False参数,跳过证书验证:

import nltk
from nltk.corpus import stopwords
nltk.download('stopwords', ssl_verify=False)

方法二:更新Python证书(长期安全方案)

macOS的Python环境常因证书缺失导致SSL验证失败,可通过以下步骤修复:

  • 打开终端,根据你的Python安装方式执行对应命令:
    • 若为系统自带Python(比如Python 3.9),运行:
      /Applications/Python\ 3.9/Install\ Certificates.command
      
      (将命令中的3.9替换为你实际使用的Python版本)
    • 若为Homebrew安装的Python(比如Python 3.10),运行:
      /usr/local/opt/python@3.10/bin/python3 -m pip install --upgrade certifi
      
  • 执行完成后重启Jupyter Notebook,再运行原代码即可。

方法三:手动下载stopwords数据集

如果上述方法无效,可手动下载并放置数据集:

  1. 下载stopwords对应的数据集包
  2. 解压后得到stopwords文件夹
  3. 将该文件夹放到macOS的NLTK数据目录:~/nltk_data/corpora/(若无对应目录,手动创建)
  4. 之后直接运行导入代码即可,无需再执行nltk.download()

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.19 09:57:41