我跟着這些指示http://www.nltk.org/install.html我的Mac上安裝NLTK模塊(10.6) 我已經安裝了Python 2.7,但是當我打開IDLE,並輸入import nltk
它給了我這個錯誤Python不能找到模塊NLTK
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import nltk
ImportError: No module named nltk
問題是該模塊安裝在另一個Python版本2.6中。我如何在python 2.7版本中安裝軟件包?我嘗試了一些在不同的答案提出的解決方案,例如我試圖在終端
export PYTHONPATH=$PYTHONPATH:/usr/local/lib/python2.7/site-packages
打字,然後用命令
sudo pip install -U nltk
再次安裝NLTK,但我得到的消息:已要求最新的/Library/Python/2.6/。所以顯然命令行export PYTHONPATH
沒有做任何事情(它仍然試圖在2.6中安裝包)或(更可能)我不明白該命令行的含義/功能。我究竟做錯了什麼?
Apple使用OS X發佈自己的Python版本,這就是爲什麼pip會感到困惑。有可能將其安裝到您的python2.7安裝,但最好的解決方案是使用[virtualenv](https://virtualenv.pypa.io/en/latest/)。 – L3viathan
http://stackoverflow.com/questions/19642368/real-difficulty-installing-nltk-on-mac-os-x-10-9 –