I asked a question about this yesterday, and some nice people helped me, but I guess I'm just stupid. I'm running Yosemite on my Mac. I've installed both python2 and python3 with Homebrew, and I've gotten both pip and pip3 from Homebrew.
Now I installed nltk with pip3
install nltk` and it works fine on python 3, but not, of course, on python 2.
So I tried pip install nltk
and I got
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)
Then I tried
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)
And of course, I still can't import nltk in python 2.
I haven't had any trouble with pip and pip3 in the past, and I haven't intentionally changed my environment. How can get import nltk
to work in python 2?
As suggested, I tried getting the version of pip:
pip -V
pip 7.1.2 from /usr/local/lib/python2.7/site-packages (python 2.7)
So it looks like it python 2, as I thought.
I also tried pip2, as recommended, but I got an exception:
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'
The last line is really strange, because it suggests that installation is being attempted not in the python 2 that I installed with Homebrew but in the python 2 that comes with the Mac.
Can you tell me what's wrong and how to rectify it?