IPython is a powerful Python shell which can be used to incorporate your libraries into a single console application. I find this extremely useful when I need to execute and experiment with functions from several small utility libraries that I have written. The first thing that you should do is to create a new IPython profile
ipython profile create new_profile_name
IPython will print the directory location where the new profile was created.
[ProfileCreate] Generating default config file: u'C:\\Users\\a\\.ipython\\profile_new_profile_name\\ipython_config.py'
[ProfileCreate] Generating default config file: u'C:\\Users\\a\\.ipython\\profile_new_profile_name\\ipython_qtconsole_config.py'
You can load this profile by executing:
ipython --profile=new_profile_name
What is great about this is that you can move the profile directory anywhere on your hard drive and then you can run IPython using that profile. This makes it possible to share the profile while working in a team. So if you move the folder profile_new_profile_name to a directory /myprojects/project_1, you can:
cd /myprojects/project_1
ipython --profile=new_profile_name
In order to load your libraries during iPython’s startup, navigate to the folder profile_new_profile_name/startup and add any startup scripts that you require there. The files here are loaded in alphabetical order.
The following startup script will load your libraries into IPython console:
import sys
print 'Importing libaries'
sys.path.append('src/lib/your_nice_library_1')
sys.path.append('../your_other_libary')
from your_nice_library_1 import *
from your_other_libary import *
Once you load IPython with this new profile, you should see:
ipython --profile=new_profile_name--colors=linux
Python 2.7.3 (default, Apr 10 2012, 23:24:47) [MSC v.1500 64 bit (AMD64)]
Type "copyright", "credits" or "license" for more information.
IPython 0.13 -- An enhanced Interactive Python.
IPython profile: new_profile_name
Importing libaries
Posts