Python and IPython consoles in spyder do not load libraries correctly unless working dir set to match location

1,460 views
Skip to first unread message

lcorrigan

unread,
Apr 2, 2012, 12:01:04 PM4/2/12
to spyd...@googlegroups.com
I have a package named 'testlib' located outside of site-packages that consists of a large tree that has all my work scripts - the path on my windows machine is on the PYTHONPATH.
If I import testlib from an outside IPython or Python session, the import takes the 2 seconds I'm used to, and the whole tree is 'seen' from the interpreter. I.e: IPython has autocomplete for all sub-items, and python can make all the calls etc.

The consoles in Spyder (Python or IPython) take no time at all during this same import, but there is nothing there at all either.  The consoles in spyder can only do the correct loading and auto-completion if I do the import AFTER setting the console's working folder to match the dir where testlib is located.
Oddly enough, I have the codeeditor set to include testlib in it's ROPE_PREFS and the editor 'see's all the sub functions and scripts as well - no dir navigation is needed.

Any ideas of why I don't have the same inspection on the spyder consoles unless I set the working path to match the lib?  I'm not always working from there - that is why I go to the trouble of setting PYTHONPATH on all our PC's.
Is there an equivalent ROPE_PREFS type thing I need to change in the spyder code for the consoles that run within it?

lcorrigan

unread,
Apr 3, 2012, 11:51:25 AM4/3/12
to spyd...@googlegroups.com
It seems the console(s) found the code after all.  
Although my console working directory is not currently the same as my testlib folder, the consoles auto-magically started showing the class members and functions in autocomplete etc.  I did a number of trials before my first post where I'd change the working directory and it would only work if I was in the same dir as testlib.  However, now it doesn't matter, it always works.
I'm guessing Spyder just takes a while for this type of code inspection? Seemed like it was just doing it in the background since it started loading and doing autocomplete correctly a few hours later (I didn't check every minute so I don't know exactly when the references were found).
Too bad it doesn't give you any indication of what it is doing. I spent a lot of time debugging packages and paths thinking I had done something wrong.

Carlos Córdoba

unread,
Apr 3, 2012, 12:41:34 PM4/3/12
to spyd...@googlegroups.com
Hi,

I think Spyder declares and uses its own PYTHONPATH. You can see what you have in it going to:

Tools > PYTHONPATH manager

Glad to hear everything worked after all for you.

Cheers,
Carlos

El 03/04/12 10:51, lcorrigan escribió:
--
You received this message because you are subscribed to the Google Groups "spyder" group.
To view this discussion on the web visit https://groups.google.com/d/msg/spyderlib/-/tIHbYPbTvBQJ.
To post to this group, send email to spyd...@googlegroups.com.
To unsubscribe from this group, send email to spyderlib+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/spyderlib?hl=en.
Reply all
Reply to author
Forward
0 new messages