[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 

 In [2]:mplt
 Out[2]:<module 'matplotlib' from 

 but mpl is masked by matplotlib.mpl:

 In [3]:mpl
 Out[3]:<module 'matplotlib.mpl' from 

 although it works from the ipython prompt

 In [4]:import matplotlib as mpl

 In [5]:mpl
 Out[5]:<module 'matplotlib' from 

 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