16

nltk.download() is hanging for me on OS X. Here is what happens:

$python
>>> Python 2.7.2 (default, Oct 11 2012, 20:14:37) 
>>> [GCC 4.2.1 Compatible Apple Clang 4.0 (tags/Apple/clang-418.0.60)] on darwin
>>> import nltk
>>> nltk.download()

showing info http://nltk.github.com/nltk_data/

After that, it completely freezes.

I installed everything according to the ntlk install page. I'm on OS X 10.8.3. On my Linux box, it just works with no problems.

Any ideas?

Jason Sundram
  • 12,225
  • 19
  • 71
  • 86
bzdjamboo
  • 555
  • 3
  • 6
  • 15

5 Answers5

37

Try running nltk.download_shell() instead as there is most likely an issue displaying the downloader UI. Running the download_shell() function will bypass it.

Jason Sundram
  • 12,225
  • 19
  • 71
  • 86
Ryan O'Neill
  • 3,727
  • 22
  • 27
  • Thanks, this really worked for me too after panlex stalled. One thing to add is I couldn't understand at first to click the letter "u" to update and then "o" - this was a slightly confusing prompt sequence. – dixon1e Jan 27 '16 at 03:22
  • 7
    Many thanks for pointing this out. As @dixon1e indicated what one should do *after* executing `nltk.download_shell()` is indeed confusing so I wanted to add a bit more to this answer. After running this command be prompted to execute a sub-command. Execute `d`, then execute `all` when prompted to download a package. This will take a *long* time, mine took 30 minutes on a fast connection. Then type `q` to return to the Python console prompt. – Jason Gilmore Jun 02 '17 at 17:55
  • 3
    Finally, I got a good solution for downloading all packages to `nltk`, command as this `nltk.download('all')`, in a while, all packages will be downloaded. – Johnny Jul 21 '18 at 10:22
9

In my case I was running nlkt.download() in a Jupyter (IPython) notebook on a Mac, and it had opened a window BEHIND the browser window without me knowing. I finally found it by Mission Control (four fingers swipe up). That's why the function was seemingly hanging.

Gandalf Saxe
  • 381
  • 3
  • 7
3

I had trouble with this, too, and I ended up with this workaround:

> cd /usr/lib -- change directory to the desired install directory

> sudo idle -- run the interactive interpreter as an administrator (superuser do)

At this point the system asks for your password before starting up idle. Then, within idle, the nltk.download() function works fine:

>>> nltk.download()

Suz
  • 3,744
  • 3
  • 23
  • 26
3

Try nltk.download('all') it worked for me!

Page Ng
  • 31
  • 1
1

For me, the problem turned out to the the SSL certificate verification error issue, which is apparently pretty common in Mac OS. And this issue arised for me even when trying nltk.download_shell().

So, the way to fix this is pretty simple. Just run the following command, with the appropriate version of Python you have installed of course, in terminal to install the SSL certificate:

open /Applications/Python\ 3.7/Install\ Certificates.command

And then nltk.download() worked fine for me.

Kristada673
  • 3,512
  • 6
  • 39
  • 93