在mac上安装nltk

nltk官网教程:http://www.nltk.org/install.html

第一步是 Install NLTK: run sudo pip install -U nltk

但是出现问题,没有 pip 命令


然后找到这个教程:http://blog.csdn.net/lqzitongyezu/article/details/47664947

按照上面这个教程,成功安装pip。

但是走到最后的第4步和第5步,又出现如下问题:

Collecting six (from nltk)

  Downloading six-1.11.0-py2.py3-none-any.whl

Installing collected packages: six, nltk

  Found existing installation: six 1.4.1

    DEPRECATION: Uninstalling a distutils installed project (six) has been deprecated and will be removed in a future version. This is due to the fact that uninstalling a distutils project will only partially uninstall the project.

    Uninstalling six-1.4.1:

Exception:

Traceback (most recent call last):

...............省略


最后找到这个博客:https://www.cnblogs.com/chxw2017/p/6837100.html

需要在sudo pip install -U nltk命令后面加上--upgrade --ignore-installed six

xxxdeMacBook-Pro:~ xxx$ sudo pip install -U nltk --upgrade --ignore-installed six

The directory '/Users/zhouziyun/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.

The directory '/Users/zhouziyun/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.

Collecting nltk

  Downloading nltk-3.2.5.tar.gz (1.2MB)

    100% |████████████████████████████████| 1.2MB 123kB/s 

Collecting six

  Downloading six-1.11.0-py2.py3-none-any.whl

Installing collected packages: six, nltk

  Running setup.py install for nltk ... done

Successfully installed nltk-3.2.5 six-1.11.0

xxxMacBook-Pro:~ xxx$ python

Python 2.7.10 (default, Jul 15 2017, 17:16:57) 

[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.31)] on darwin

Type "help", "copyright", "credits" or "license" for more information.

>>> import nltk

>>> 

终于 import nltk 没有报错了。

你可能感兴趣的:(在mac上安装nltk)