Python 3 无法使用 NLTK 3
Python 3 not working with NLTK 3
我刚刚更新到 Python3...嗯,有点。我可以 运行 在终端中 Python2.7.9 和 Python3。我也有 NLTK3,它通常与 Python2.7 一起使用,但有时某些东西不起作用。然而,当我在 MacOSX 终端中切换到 Python3 时,它不会让我导入 nltk(或与此相关的任何其他内容)。有没有简单的解决方法?
>>> python 3
>>> import nltk
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: no module named 'nltk'
库不会在 python 版本之间继承。
您也需要为 python 3 安装该库。
Python 2 + Python 3 + library
在 Mac OS X:
# Install pip
$ curl bootstrap.pypa.io/get-pip.py | python
$ curl bootstrap.pypa.io/get-pip.py | python3
在 Ubuntu:
# Install pip
$ sudo apt-get install pip
$ sudo apt-get install pip3
然后:
# Install NLTK on python and python3
$ sudo pip install -U nltk
$ sudo pip3 install -U nltk
# Install Numpy
$ sudo pip install -U numpy
$ sudo pip3 install -U numpy
$ python
>>> import nltk
>>> nltk.download('all')
我刚刚更新到 Python3...嗯,有点。我可以 运行 在终端中 Python2.7.9 和 Python3。我也有 NLTK3,它通常与 Python2.7 一起使用,但有时某些东西不起作用。然而,当我在 MacOSX 终端中切换到 Python3 时,它不会让我导入 nltk(或与此相关的任何其他内容)。有没有简单的解决方法?
>>> python 3
>>> import nltk
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: no module named 'nltk'
库不会在 python 版本之间继承。
您也需要为 python 3 安装该库。
Python 2 + Python 3 + library
在 Mac OS X:
# Install pip
$ curl bootstrap.pypa.io/get-pip.py | python
$ curl bootstrap.pypa.io/get-pip.py | python3
在 Ubuntu:
# Install pip
$ sudo apt-get install pip
$ sudo apt-get install pip3
然后:
# Install NLTK on python and python3
$ sudo pip install -U nltk
$ sudo pip3 install -U nltk
# Install Numpy
$ sudo pip install -U numpy
$ sudo pip3 install -U numpy
$ python
>>> import nltk
>>> nltk.download('all')