Real difficulty installing NLTK on MAC OS X 10.9

10,843

Solution 1

If you are not able to install pip try: How do I install pip on macOS or OS X?

Then try running: pip install nltk

If that fails you might need to run: sudo pip install nltk

Once that is done you should be able to import nltk

I just installed nltk on mavericks so I can confirm that it works.

Solution 2

For OS X El Captain do sudo pip install --upgrade nltk --ignore-installed six

Reimport nltk in python code afterwards

Solution 3

I did it on Win 8 & 7 machine prior just fine, but just got a MacBookPro. You are right nothing is clear for Mac, and all you get half the time is arrogant answers from some of the people who do this for a living - not everyone can be a fulltime programmer you know. Any how I figured it out by watching this http://www.youtube.com/watch?v=c9LlK2iu7OA

  1. Download the developer kit
  2. install the dev kit
  3. open terminal
  4. Go to Home brew and scroll to the bottom of the page for the code
  5. Paste code into terminal
  6. Run Home Brew

Once you are up and running with homebrew and all the Dev kits are install the first unix/MAC NLTK instructions will work (http://nltk.org/install.html) in homebrew.. I have no idea why they don't list this on the NLTK page itself. Very counterintuitive. If you need more specifics Watch this video - it was a savior

Share:
10,843
Isaac
Author by

Isaac

Updated on June 14, 2022

Comments

  • Isaac
    Isaac almost 2 years

    I'm new to Python/Mac OS and I'm looking to work through the NLTK textbook, but I'm having some problems installing it. I've been looking for solutions to this for a while now but unfortunately all the solutions don't seem to be able to work for me (or I'm misunderstanding exactly how to utilize them).

    The basic problem I'm having is that NLTK just doesn't seem to be installed despite following the instructions. The following code gives me an error that no such module exists:

    import nltk
    nltk.download()
    

    I think the problem I'm having is that pip/easy_install aren't correctly installing. From reading about a bit I suspects that this may be to do with having two versions of Python on my computer (the Mac OS X pre-installed one, and the one which I installed.) Although, at the moment I'm not sure how to check this, or which version of python the setups are utilizing. So as an initial step, how do I quickly check whether there are multiple versions of python installed on my machine?

    If this turns out not to be the root cause of the problem, all of the instructions for installing pip on the following page do not work for me (all the commands return syntax errors): http://www.pip-installer.org/en/latest/installing.html.

    I'm sorry for the unorganized approach to this problem, hopefully with a few pointers I'll be able to work out where I'm going wrong.