Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

nltk.download() hangs on OS X

Tags:

python

nltk

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?

like image 481
bzdjamboo Avatar asked May 16 '13 22:05

bzdjamboo


People also ask

What is NLTK download (' Wordnet ')?

The argument to nltk. download() is not a file or module, but a resource id that maps to a corpus, machine-learning model or other resource (or collection of resources) to be installed in your NLTK_DATA area. You can see a list of the available resources, and their IDs, at http://www.nltk.org/nltk_data/ .

How do I manually download NLTK?

Run the command python -m nltk. downloader all . To ensure central installation, run the command sudo python -m nltk. downloader -d /usr/local/share/nltk_data all .


2 Answers

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.

like image 152
Ryan O'Neill Avatar answered Nov 22 '22 05:11

Ryan O'Neill


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.

like image 27
Gandalf Saxe Avatar answered Nov 22 '22 07:11

Gandalf Saxe