[IPython-user] Can "import" module, then "run" cannot find it
Sat Feb 20 21:37:07 CST 2010
I love IPython, especially (as a former awk user) now that I
have discovered the brilliant .
However, after extensive reading, Googling, and searching in
online documentation, I cannot understand why I should be able to
_import_ a module -- i.e., the module is in the path and is found --
but then not be able to _run_ it.
-- The pathname of the module is /home/tbaker/shawkle/shawkle.py.
-- The directory of test data is at /home/tbaker/shawkle/testdata.
This is where I want to run ipython (and shawkle), because
shawkle.py is designed to access data in the Working Directory.
This is what happens:
/home/tbaker/shawkle/testdata> ipython # I start IPython
Python 2.5.2. ... blah blah...
In : import sys
In : print sys.path
['', '/usr/bin', ... '/home/tbaker/shawkle'] # '/home/tbaker/shawkle' is in search path
In : pwd # I am indeed in '/home/tbaker/shawkle/testdata'
In : import shawkle # "import" finds 'shawkle.py' with no problem
In : edit shawkle # editing 'shawkle.py' works fine
Editing... done. Executing edited code... # vim shows me I am editing '~/shawkle/shawkle.py'
In : edit shawkle.datashuffle # editing a particular function works fine
Editing... done. Executing edited code... # vim says I am editing ~/shawkle/shawkle.py'
In : run shawkle
ERROR: File 'shawkle.py' not found. # So why can it now not find 'shawkle.py'??
In : run ../shawkle.py # Giving a relative reference seems to work...
My question is: how is it that IPython can find shawkle.py to import it,
edit it, and execute the edited code, but is unable to find the same file
in order to "run" it?
I have tried adding '~/shawkle' to the search path as well
(using sys.path.append), but that does not fix the problem.
I have also tried putting a special PYTHONPATH in my bash
profile, but that also does not seem to make a difference, and I
have commented it out (leaving just PATH).
I use python 2.5.2-1 and cygwin 1.7.1-1 with Windows XP.
Any insights into this puzzling situation gratefully received...
Tom Baker <firstname.lastname@example.org>
More information about the IPython-user