[IPython-dev] IPython.Extensions on sys.path

Walter Dörwald walter at livinglogic.de
Fri Nov 3 10:23:52 CST 2006


Fernando Perez wrote:

> [...]
> 
> I just added this code to the main ipython starter script:
> 
> # Start by cleaning up sys.path: Python automatically inserts the script's
> # base directory into sys.path, at the front.  This can lead to unpleasant
> # surprises.
> import sys
> sys.path.pop(0)
> 
> Now, the front of sys.path is identical for a plain python and an
> ipython shell.  The only difference is that under ipython, the very
> last two entries are:
> 
> '/home/fperez/usr/lib/python2.4/site-packages/IPython/Extensions',
> '/home/fperez/.ipython']
> 
> which don't exist for plain Python.  I don't see these as a big problem,
> though.
> 
> If others disagree, let us know.

This breaks running the start script directly. With the current version
I get a sys.path that looks like this:

['',
 '/usr/local/lib/python2.5/site-packages/mpcp-1.5-py2.5.egg',
 '/usr/local/lib/python2.5/site-packages/docutils-0.4-py2.5.egg',
 '/usr/local/lib/python2.5/site-packages/ipython-0.7.2-py2.5.egg',
 '/usr/local/lib/python2.5/site-packages/setuptools-0.6c3-py2.5.egg',
 '/usr/local/lib/python2.5/site-packages/cssutils-0.9a6-py2.5.egg',
 '/usr/local/lib/python2.5/site-packages/simplegeneric-0.6-py2.5.egg',
 '/usr/local/lib/python2.5/site-packages/path-2.1-py2.5.egg',
 '/var/home/walter/dist-py',
 '/usr/local/lib/svn-python',
 '/usr/local/lib/python25.zip',
 '/usr/local/lib/python2.5',
 '/usr/local/lib/python2.5/plat-linux2',
 '/usr/local/lib/python2.5/lib-tk',
 '/usr/local/lib/python2.5/lib-dynload',
 '/usr/local/lib/python2.5/site-packages',
 '/var/home/walter/pythonroot',
 '/usr/local/lib/python2.5/site-packages/ipython-0.7.2-py2.5.egg/IPython/Extensions',
 '/var/home/walter/.ipython']

Note that the IPython/Extensions directory from the globally installed
IPython has been added. Commenting out the sys.path.pop(0) gives me:

['',
 '/var/home/walter/checkouts/IPython/current',
 '/usr/local/lib/python2.5/site-packages/mpcp-1.5-py2.5.egg',
 '/usr/local/lib/python2.5/site-packages/docutils-0.4-py2.5.egg',
 '/usr/local/lib/python2.5/site-packages/ipython-0.7.2-py2.5.egg',
 '/usr/local/lib/python2.5/site-packages/setuptools-0.6c3-py2.5.egg',
 '/usr/local/lib/python2.5/site-packages/cssutils-0.9a6-py2.5.egg',
 '/usr/local/lib/python2.5/site-packages/simplegeneric-0.6-py2.5.egg',
 '/usr/local/lib/python2.5/site-packages/path-2.1-py2.5.egg',
 '/var/home/walter/dist-py',
 '/usr/local/lib/svn-python',
 '/usr/local/lib/python25.zip',
 '/usr/local/lib/python2.5',
 '/usr/local/lib/python2.5/plat-linux2',
 '/usr/local/lib/python2.5/lib-tk',
 '/usr/local/lib/python2.5/lib-dynload',
 '/usr/local/lib/python2.5/site-packages',
 '/var/home/walter/pythonroot',
 '/var/home/walter/checkouts/IPython/current/IPython/Extensions',
 '/var/home/walter/.ipython']

Servus,
   Walter


More information about the IPython-dev mailing list