[IPython-user] executing from module import function at startup

Phil Austin paustin@eos.ubc...
Mon Jan 12 17:43:33 CST 2009


(repeat post -- the first seems to have triggered my spam filter)

 Hi, I'm trying to make ipython do:

 import matplotlib as mpl

 at the start of every session, and am running into problems
 with this particular module.  Specifically, I've edited
 ipy_user_conf.py to read:

 def main():
    o = ip.options
    import ipy_autoreload
    ip.ex('import matplotlib as mplt')
    ip.ex('import matplotlib.pyplot as plt')
    ip.ex('import numpy as np')
    ip.ex('import scipy as sp')
    ip.ex('import matplotlib as mpl')
    # An example on how to set options
    #o.autocall = 1

 This works as expected for the first 4 imports:

 In [1]:np
 Out[1]:<module 'numpy' from 
'/home/phil/usr64/lib/python2.5/site-packages/numpy/__init__.pyc'>

 In [2]:mplt
 Out[2]:<module 'matplotlib' from 
'/home/phil/usr64/lib/python2.5/site-packages/matplotlib/__init__.pyc'>

 but mpl is masked by matplotlib.mpl:

 In [3]:mpl
 Out[3]:<module 'matplotlib.mpl' from 
'/home/phil/usr64/lib/python2.5/site-packages/matplotlib/mpl.pyc'>

 although it works from the ipython prompt

 In [4]:import matplotlib as mpl

 In [5]:mpl
 Out[5]:<module 'matplotlib' from 
'/home/phil/usr64/lib/python2.5/site-packages/matplotlib/__init__.pyc'>

 this is with the current ipython revision 1147 and
 mpl 0.98.3

 thanks for any pointers, Phil





More information about the IPython-user mailing list