ipython/ipython — Issue #1438: from cherrypy import expose fails when running script form parent directory
Author: canute
Created: 2012-02-25 23:27:08+00:00
State: open

Not sure if this is a cherrypy bug. It has only happened with cherrypy.

Basically do this:
Make a directory 'cherrypy'
Create an empty file cherrypy/__init__.py
Create a file cherrypy/test.py containing the following:
from cherrypy import expose

Running
ipython test.py
inside the cherrypy directory works fine. As does running python2 test.py

Running
python2 cherrypy/test.py
inside root directory works fine.

Running
ipython cherrypy/test.py
from the root directory results in:

---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
/usr/lib/python2.7/site-packages/ipython-0.12-py2.7.egg/IPython/utils/py3compat.pyc in execfile(fname, *where)
173 else:
174 filename = fname
--> 175 __builtin__.execfile(filename, *where)

/home/canute/cherrypy/test.py in ()
----> 1 from cherrypy import expose

ImportError: cannot import name expose