I think other may ask this before but I cannot find it. My question is, I have these statements in my .ipython/ipy_user_conf.py
:
ip.ex('import matplotlib as mat')
ip.ex('import matplotlib.pyplot as plt')
ip.ex('import numpy as np')
ip.ex('import pupynere as pu')
ip.ex('import g')
ip.ex('import bsite')
ip.ex('import csvf')
ip.ex('import pandas as pa')
ip.ex('import pickle as pk')
ip.ex('import mathex as mathex')
ip.ex('import os as os')
ip.ex('import re as re')
ip.ex('import scipy as sp')
ip.ex('import mpl_toolkits.basemap as bmp')
ip.ex('from mpl_toolkits.basemap import cm')
Then If I use python in ipython shell, these modules will be loaded directly when I start ipython, but if I have a python script, eg., ba_plot.py
used to make some plots. I debugged the script by an interactive way in the ipython, but then I want to run it within the shell terminal, like:
chaoyue@chaoyue-Aspire-4750:~$ python ba_plot.py
but before this, each time I need to copy at the beginning of ba_plot.py
file the following again:
import matplotlib as mat
import matplotlib.pyplot as plt
import numpy as np
import pupynere as pu
import g
import bsite
import csvf
import pandas as pa
import pickle as pk
import mathex as mathex
import os as os
import re as re
import scipy as sp
import mpl_toolkits.basemap as bmp
from mpl_toolkits.basemap import cm
Because otherwise it will complain it cannot find the module. So, is there anyway that I can avoid do this by including some header file at the beginning of my python script while in the header file all these modules are imported? By this way, I need only to add on line at the beginning of my python script.