我問了一個question關於這個昨天,一些好人幫助我,但我想我只是愚蠢。我在我的Mac上運行Yosemite。我已經用Homebrew安裝了python2和python3,並且從Homebrew中獲得了pip和pip3。pip安裝在優勝美地與自制的
現在我安裝NLTK與pip3
安裝nltk`並能正常工作在Python 3中,但當然不是,在蟒蛇2.
所以,我想pip install nltk
,我得到了
pip install nltk
Requirement already satisfied (use --upgrade to upgrade): nltk in /usr/local/lib/python3.4/site-packages
Requirement already satisfied (use --upgrade to upgrade): six>=1.9.0 in /usr/local/lib/python3.4/site-packages (from nltk)
然後我試圖
pip install --upgrade nltk
Requirement already up-to-date: nltk in /usr/local/lib/python3.4/site-packages
Requirement already up-to-date: six>=1.9.0 in /usr/local/lib/python3.4/site-packages (from nltk)
和當然,我仍然無法在Python導入NLTK 2.
過去我沒有對pip和pip3有任何問題,我也沒有故意改變我的環境。如何才能讓import nltk
在Python 2中工作?
至於建議,我試圖讓PIP的版本:
pip -V
pip 7.1.2 from /usr/local/lib/python2.7/site-packages (python 2.7)
所以它看起來像它蟒蛇2,因爲我以爲。
我也試過PIP2,作爲推薦,但我有一個例外:
pip2 install nltk
Collecting nltk
Using cached nltk-3.0.5.tar.gz
Collecting six>=1.9.0 (from nltk)
Using cached six-1.9.0-py2.py3-none-any.whl
Building wheels for collected packages: nltk
Building wheel for nltk failed: [Errno 13] Permission denied: '/Users/saul/Library/Caches/pip/wheels/f6'
Failed to build nltk
Installing collected packages: six, nltk
Found existing installation: six 1.8.0
Uninstalling six-1.8.0:
Exception:
Traceback (most recent call last):
File "/usr/local/lib/python2.7/site-packages/pip/basecommand.py", line 211, in main
status = self.run(options, args)
File "/usr/local/lib/python2.7/site-packages/pip/commands/install.py", line 311, in run
root=options.root_path,
File "/usr/local/lib/python2.7/site-packages/pip/req/req_set.py", line 640, in install
requirement.uninstall(auto_confirm=True)
File "/usr/local/lib/python2.7/site-packages/pip/req/req_install.py", line 716, in uninstall
paths_to_remove.remove(auto_confirm)
File "/usr/local/lib/python2.7/site-packages/pip/req/req_uninstall.py", line 125, in remove
renames(path, new_path)
File "/usr/local/lib/python2.7/site-packages/pip/utils/__init__.py", line 315, in renames
shutil.move(old, new)
File "/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 303, in move
os.unlink(src)
OSError: [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/six-1.8.0.dist-info/DESCRIPTION.rst'
的最後一行是真的很奇怪,因爲它表明,安裝正在沒有嘗試在我家釀安裝了蟒蛇2但是在Mac中附帶的python 2中。
你能告訴我什麼是錯的,以及如何糾正它?
從命令行嘗試'pip -V'來查看您正在使用哪個點。 – Alexander