nltk/nltk — Issue #106: Installing NLTK on Mac
Author: alexrudnick
Created: 2012-01-17 06:26:13+00:00
State: open

Please update this ticket with any problems relating to installation of
NLTK on Macintosh computers.

OS version: 10.?.?
NLTK version:
Python version

What problem did you encounter with installation?

Did you find any fixes? Please suggest ways to improve our installation
instructions.

Migrated from http://code.google.com/p/nltk/issues/detail?id=527

earlier comments

johnnewman00 said, at 2010-03-15T00:39:38.000Z:

Hi Steven

Mac OS 10.4.11
Python 2.5.4 (r254:67917, Dec 23 2008, 14:57:27)
[GCC 4.0.1 (Apple Computer, Inc. build 5363)] on darwin
Macports installed

john-newmans-computer:~ johnnewman$ sudo port install py26-nltk
Password:
---> Computing dependencies for py26-nltk
---> Building tk
Error: Target org.macports.build returned: shell command " cd
"/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_x11_tk/
work/tk8.5.8/unix" && /usr/bin/make -j2 all " returned error 2
etc etc etc
Error: The following dependencies failed to build: tk
Error: Status 1 encountered during processing.

In Python 2.5.4
>>> import nltk
Traceback (most recent call last):
File "", line 1, in
ImportError: No module named nltk

John

StevenBird1 said, at 2010-03-15T00:45:23.000Z:

Since you have Python 2.5, please install py25-nltk, not py26-nltk.

johnnewman00 said, at 2010-03-15T14:29:26.000Z:

Results with py25-nltk:

john-newmans-computer:~ johnnewman$ python
Python 2.5.4 (r254:67917, Dec 23 2008, 14:57:27)
[GCC 4.0.1 (Apple Computer, Inc. build 5363)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

john-newmans-computer:~ johnnewman$ sudo port install py25-nltk
---> Computing dependencies for py25-nltk
---> Building tk
Error: Target org.macports.build returned: shell command " cd
"/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_x11_tk/work/tk8.5.8/unix" && /usr/bin/make -j2 all "
returned error 2
.....many such lines...
/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_x11_tk/work/tk8.5.8/unix/../generic/tk3d.c:1373: error:
parse error before ')' token
make: *** [tkArgv.o] Error 1
make: *** Waiting for unfinished jobs....
make: *** [tk3d.o] Error 1

Error: The following dependencies failed to build: py25-matplotlib py25-configobj python25 tk py25-dateutil py25-setuptools py25-tz py25-numpy atlas
gcc43 gmp mpfr gzip py25-nose py25-pyobjc-cocoa py25-pyobjc py25-py2app py25-altgraph py25-bdist_mpkg py25-macholib py25-modulegraph py25-
pyobjc2 py25-pyobjc2-cocoa py25-yaml
Error: Status 1 encountered during processing.
Before reporting a bug, first run the command again with the -d flag to get complete output.

steven.mccauley said, at 2010-05-31T19:55:37.000Z:

Howdy-

I performed a manual installation of NLTK on a Mac, which supposedly went through successfully. When I go
to "import nltk" either through IDLE or the command line, though, no module is detected. Any advice is much
appreciated.

(In the manual installation, I'm installing NLTK straight to the general hard disk. Does it need to go somewhere
else, i.e. the python folder?)

Thanks-
Steve

StevenBird1 said, at 2010-05-31T22:04:16.000Z:

You probably have two versions of Python, with NLTK installed in one of them, while you're using the other one.
Please see the thread on nltk-users for suggestions for what to do:

http://groups.google.com/group/nltk-users/browse_thread/thread/e14b647243ca5b66

robinseguy said, at 2011-11-18T04:28:58.000Z:

Hi,

I have the same problem: I installed MacPorts and NLTK (using "sudo port install python26"), but the importation fails:

IDLE 2.6.1
>>> import nltk

Traceback (most recent call last):
File "", line 1, in
import nltk
ImportError: No module named nltk
>>>

Many thanks in advance for your help!

Robin