Re: [spyder] Problems of identifying nltk in Spyder

3,168 views
Skip to first unread message

David Verelst

unread,
Mar 29, 2013, 6:48:47 AM3/29/13
to spyder
Hi,

What version of spyder are you using, and from what source did you install it?

It seems Spyder is not aware of the location of several python modules: I can see from your spyder traceback that pylab also fails to load, have you installed matplotlib, or can you import pylab from the normal python console? In Spyder, can you import any other modules you have installed?

In theory your issue should be fixed by adding the directories of your modules to your PYTONPATH environment variable.
In Spyder you can use the PYTHONPATH manager for this: Tool > PYTHONPATH Manager and add the path to your nltk module. Note that this shouldn't be necessary, so their is either something wrong with your Spyder installation, PYTHONPATH or nltk install.

You could check which paths are set in your PYTHONPATH environment variable, from a Python/Spyder console:
import sys
for p in sys.path: print k
I don't know how it is on Mac exactly, but I think you should see some entries that contain python/site-packages.

There have been some issues on Mac that got solved in the latest beta's recently. If you are not running the latest beta, you could try to install that one.

Regards,
David


On 28 March 2013 09:08, Måns Magnusson <mons.ma...@gmail.com> wrote:
Hi all!

I have a problem when i try to use nltk in Spyder. I've installed the nltk package in Python so when I use python in the console (see the debug code 3 below) it works just fine. But When I try to use it in Spyder it doesn't work. Ive tried both with default values of python path (in Spyder-Preferences-Console-Advanced-Python executable) and with /usr/bin/python but it does not work. See the output below.
Im quite new to Python.

When I start Spyder (in the ordinary way) - /Applications/Spyder.app/Contents/MacOS/python
Python 2.7.3 (default, Jul 24 2012, 20:20:13)
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.9.00)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

Imported NumPy 1.6.2, SciPy 0.11.0, Matplotlib 1.2.0
Type "scientific" for more details.

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


When I start Spyder (in the other suggested path) - /usr/bin/python

Python 2.7.2 (default, Jun 20 2012, 16:23:33)
[GCC 4.2.1 Compatible Apple Clang 4.0 (tags/Apple/clang-418.0.60)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
Traceback (most recent call last):
  File "/Applications/Spyder.app/Contents/Resources/lib/python2.7/spyderlib/scientific_startup.py", line 16, in <module>
    from pylab import *  #analysis:ignore
ImportError: No module named pylab
>>> import nltk
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named nltk
>>>


And if I run python in the terminal - it works!?

Manss-MacBook-Pro-2:~ mansmagnusson$ python
Python 2.7.3 (v2.7.3:70274d53c1dd, Apr  9 2012, 20:52:43)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import nltk
>>>


--
You received this message because you are subscribed to the Google Groups "spyder" group.
To unsubscribe from this group and stop receiving emails from it, send an email to spyderlib+...@googlegroups.com.
To post to this group, send email to spyd...@googlegroups.com.
Visit this group at http://groups.google.com/group/spyderlib?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

David Verelst

unread,
Mar 30, 2013, 6:00:08 AM3/30/13
to spyder
Hi Seymour,

What version of Spyder are you running?

Please note that my previous example had an error, it should have been:
import sys
for p in sys.path: print p (and not print k of course...)
-> can you post a comparison between the PYTHONPATH as seen from Spyder and your normal Python console?

I've never used WinPython, so I am not familiar with it's workings (on Linux here). But it almost sounds like you have a WinPython installation next to another Python installation on your system. If so, make sure you install your modules you want to use with Spyder in the WinPython environment.

Regards,
David





On 29 March 2013 20:02, <chun...@gmail.com> wrote:
Hey David,

I have a similar problem with JPype and Neo4j. They are working very fine when I use on Console. I got Spyder within WinPython and it only sees the modules that are in WinPython. All others modules that I previously installed are not seen by Spyder. I added the paths of these modules into Spyder but still did not work. Can you give me details of how I am going to set PYTHONPATH in windows 7?

Thanks,
Seymour

David

unread,
Apr 2, 2013, 6:01:21 PM4/2/13
to spyd...@googlegroups.com
From the output you have posted, it looks to me as if you have 3 different python installations - 2.7.2, 2.7.3 (default, Jul 24 2012, 20:20:13)  and 2.7.3 (v2.7.3:70274d53c1dd, Apr  9 2012, 20:52:43) . It seems that nltk is only installed for one of these python versions and not for the others. If you type "which python" in the terminal, this might tell you the correct interpreter path to use

Carlos Córdoba

unread,
Apr 7, 2013, 11:56:57 AM4/7/13
to spyd...@googlegroups.com
Hi,

What Spyder version are you using? I think I fixed this problem in beta4, so if you are using an older version please update.

Cheers,
Carlos

El 28/03/13 03:08, Måns Magnusson escribió:
Reply all
Reply to author
Forward
0 new messages