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. 然后接着运行代码

python安装nltk遇到的坑_第1张图片
链接:https://pan.baidu.com/s/1UJtEZHYF-Kp9voaTMWlNUg
提取码:06mv

你可能感兴趣的:(python)