Invalid syntax when trying to install NLTK on OS 10.10.5

124 views
Skip to first unread message

Thomas Beard

unread,
Feb 21, 2017, 9:55:00 AM2/21/17
to nltk-users
Sorry about the basic nature of the question, but I'm new to programming/machine learning and simply can't figure this out. Also, related questions here haven't been able to solve this for me. I'm attempting to install NLTK following the instructions for Mac OS, but I just get an invalid syntax error for everything.  I included a screenshot that shows this in the terminal.

Not sure if there's something simple I'm missing. I'm running Python 3.6(that I downloaded) on OS 10.10.5. The Mac did come pre-installed with an earlier version of Python (2.7), not sure if this is an issue.

Appreciate the help.



Screenshot 2017-02-21 22.22.50.png

George Orton

unread,
Feb 21, 2017, 10:00:12 AM2/21/17
to nltk-...@googlegroups.com
Hi, To install to Python 3. you need to use pip3 instead of pip. So run:
sudo pip3 install -U nltk
at the terminal prompt. Good Luck, George

--
You received this message because you are subscribed to the Google Groups "nltk-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nltk-users+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
<Screenshot 2017-02-21 22.22.50.png>

George Orton

unread,
Feb 21, 2017, 10:08:49 AM2/21/17
to nltk-...@googlegroups.com
PS. Do you have pip installed? I believe the Invalid syntax error is indicating you do not have access to the command pip. Try googling install pip and that should give you some guidance on how to proceed. George

Constantin Orăsan

unread,
Feb 21, 2017, 10:20:51 AM2/21/17
to nltk-...@googlegroups.com
He is running pip command in the python interpreter so it will definitely not work :) 

Thomas make sure you install pip and run it in the terminal not from within the python interpreter.


Thomas Beard

unread,
Feb 22, 2017, 6:08:17 AM2/22/17
to nltk-users
That was the problem, thanks.  However, when I run Python 3.6, it still won't allow me to import nltk.  I used sudo pip to install it on 2.7 (in addition to pip3) and for some reason there I'm able to import the library.  Any idea on why it won't work with the 3.6 version?  

George Orton

unread,
Feb 22, 2017, 9:56:31 AM2/22/17
to nltk-...@googlegroups.com
Hi, Are you unable to import nltk into Python 3.6 or are you just unable to access the nltk library? If it is just the library then you will need to download that separately. If you are unable to import nltk once in Python 3.6 then I am not sure what the problem is. George

Thomas Beard

unread,
Feb 23, 2017, 1:53:52 PM2/23/17
to nltk-users
I had been unable to import nltk into Python 3.6, but I fixed the problem with:

pip3 install --user --upgrade nltk
Reply all
Reply to author
Forward
0 new messages