473,383 Members | 1,815 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

How do I import nltk in python?

2
Hi. I'm totally new to Python and only have a little experience with C++. So, to begin with, I don't really know what I'm doing. I installed nltk three times - each time it said the installation was successful. But trying to import nltk only results in an error message. I tried what I found on these pages: http://groups.google.com/group/nltk-users/browse_thread/thread/509dac376bf06300?fwc=1 and http://www.nltk.org/download. This is what happened:

Expand|Select|Wrap|Line Numbers
  1. Python 2.6.4 (r264:75821M, Oct 27 2009, 19:48:32) 
  2. [GCC 4.0.1 (Apple Inc. build 5493)] on darwin
  3. Type "help", "copyright", "credits" or "license" for more information.
  4.  
  5. >>> import nltk
  6. Traceback (most recent call last):
  7.   File "<stdin>", line 1, in <module>
  8. ImportError: No module named nltk
  9.  
  10. >>> cd /tmp/nltk-installer
  11. Traceback (most recent call last):
  12.   File "<stdin>", line 1, in <module>
  13. NameError: name 'cd' is not defined
  14.  
  15. >>> sudo python setup.py install
  16.   File "<stdin>", line 1
  17.     sudo python setup.py install
  18.               ^
  19. SyntaxError: invalid syntax
  20.  
  21. >>> sudo easy_install -U py
  22.   File "<stdin>", line 1
  23.     sudo easy_install -U py
  24.                     ^
  25. SyntaxError: invalid syntax
  26. >>> 
  27.  
Any ideas? I'm sure it's something really simple. ^_^

Thanks!
Aug 27 '10 #1
2 20189
bvdet
2,851 Expert Mod 2GB
If you have more than one version of Python installed, you may have installed nltk to a different version of Python than the version currently active.
Aug 29 '10 #2
RSJinx
2
Thank you! I figured it out. Like I said, totally new to this, and I didn't realize that I needed to just be in the terminal, not python, to make those troubleshooting commands work. It all works now. : )
Aug 29 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: DogWalker | last post by:
Python 2.3.3 failed to import the _sre distributed with it. Said it couldn't find it but it could find, for instance, _csv which is in the same folder. I replaced the version of _sre.pyd of...
0
by: vincent Salaun | last post by:
hi all, here's my problem : I've embedded a python interpreter in our java application (based on the NetBeans palteforrm) using the Jython API : http://www.jython.org/docs/javadoc/index.html...
1
by: ekyungchung | last post by:
I did install the python 2.4 and nltk. I am trying to follow the tutorial, but I kept getting error messages about importing corpus as follows ===================================================...
1
by: Andrew Marlow | last post by:
guys, I have been using libxml2 with python with no problems for just over a week but now I come to see if my script will work in someone else's environment and the libxml2 import fails. I am...
3
by: Anthony Irwin | last post by:
Hi, I have written a python script that works perfectly in python 2.4.4 and python 2.4.3 but when I try to use the same script on an older system with python 2.2.3 I get the following error. ...
16
by: ssecorp | last post by:
Is there a way to view all the modules I have available for import from within Python? Like writing in the interpreter: import.modules Also, is there anything like Cpan for Python?
5
by: hussainsaiger | last post by:
I am trying to convert a python module (that contains the use of NLTK.Corpus) by jythonc. It is not able to include nltk dependencies within the java class it creates. So when i use this class in...
3
by: Simon Strobl | last post by:
Hello, a program of mine, which is supposed to be used in a project, uses nltk. I want the other users to be able to use my program without having to fiddle around with their environment....
0
by: Anna Butt | last post by:
Hi, I have a problem with a module in python. When I try to execute it I have this error: 00019|nox|ERR:Cannot change the state of 'pymyswitch' to INSTALLED: 'pymyswitch' ran into an...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.