Automatic Python imports.


At the interactive Python prompt, I found myself wasting a significant amount of time by repeatedly writing statements such as import urllib2, os, socket. Every time that I opened a new Python session, I needed to re-import all of the libraries that I intended to work with. The autoimp module imports all available Python modules automatically, similarly to Matlab: The modules imported from autoimp are proxy objects which lazily load when they are first used. To properly use autoimp, you should place the following code in your PYTHONSTARTUP file: Now, all modules are automatically imported and made available in your interactive Python sessions. For IPython, you can instead add the following line to .ipython/profile_default/ If you are using an editor that doesn't support either of these startup options, see note [1].


Current Version

Version 1.0.2 source code is available.

Version History

Version history (changelog):


The autoimp source code and supporting documentation have been placed in the public domain.

Please send patches and bug reports to my e-mail address: - Connelly Barnes


1. Alternatively, for editors such as IDLE which do not load the PYTHONSTARTUP file after running a script, you can (a) patch your editor or (b) use a hack to circumvent the problem: add the following code to Lib/site-packages/
    import autoimp; autoimp._export_builtins()
This hack will cause all available modules to be placed in the builtin namespace of every Python script which is run; this can presumably cause hard-to-find bugs. You have been warned.