python安装nltk遇到的坑

错误描述

错误1

	ERROR: Command errored out with exit status 1:
    command: 'c:\users\administrator\appdata\local\programs\python\python35\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\ADMINI~1\\AppData\\Local\\Temp\\pip-install-paavg_gy\\regex\\setup.py'"'"'; __file__='"'"'C:\\Users\\ADMINI~1\\AppData\\Local\\Temp\\pip-install-paavg_gy\\regex\\setup.p
y'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\ADMINI~1\AppData\Local\Temp\pip-record-upni8toj\install-record.txt' --single-version-externally-managed --compile --install-headers 'c
:\users\administrator\appdata\local\programs\python\python35\Include\regex'
    cwd: C:\Users\ADMINI~1\AppData\Local\Temp\pip-install-paavg_gy\regex\
    Complete output (13 lines):
    running install
    running build
    running build_py
    creating build
    creating build\lib.win-amd64-3.5
    creating build\lib.win-amd64-3.5\regex
    copying regex_3\__init__.py -> build\lib.win-amd64-3.5\regex
    copying regex_3\regex.py -> build\lib.win-amd64-3.5\regex
    copying regex_3\_regex_core.py -> build\lib.win-amd64-3.5\regex
    copying regex_3\test_regex.py -> build\lib.win-amd64-3.5\regex
    running build_ext
    building 'regex._regex' extension
    error: Microsoft Visual C++ 14.0 is required. Get it with "Build Tools for Visual Studio": https://visualstudio.microsoft.com/downloads/

错误2

  Resource punkt not found.
  Please use the NLTK Downloader to obtain the resource:

  >>> import nltk
  >>> nltk.download('punkt')

  For more information see: https://www.nltk.org/data.html

  Attempted to load tokenizers/punkt/english.pickle

解决方案

问题一:

  1. 直接安装 14.0.exe 可执行文件,大小4G左右

问题二:

  1. nltk_data文件夹拷贝到所需要的位置 我的是C:\Users\Administrator\AppData\Roaming\nltk_data
  2. 根据问题二描述我找不到Attempted to load tokenizers/punkt/english.pickle,将 nltk_data 中对应的 punkt 文件解压缩
  3. 然后接着运行代码

在这里插入图片描述
链接:https://pan.baidu.com/s/1UJtEZHYF-Kp9voaTMWlNUg
提取码:06mv

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值