Module Name Conflicts

Rocco Moretti roccomoretti at
Fri Aug 19 16:00:58 CEST 2005

torched_smurf at wrote:
> I have a java program in a package called 'cmd'. This of course
> conflicts with the builtin python package of the same name. The thing
> is, I need to be able to import from both of these packages in the same
> script. I can import either one first, but any future attempt to import
> from cmd.* will look up the first cmd that was imported, so the second
> package is essentially eclipsed. I've tried fiddling with sys.path and
> sys.packageManager.searchPath, to no avail. To answer the obvious first
> suggestion, no I can't rename the java package to 'Cmd' or anything
> like that. Any ideas?
> -Smurf

Never used it myself, but you can try to use the builtin 'imp' module.

Python Library Reference
3.21 imp -- Access the import internals

This module provides an interface to the mechanisms used to implement 
the import statement. It defines the following constants and functions:


More information about the Python-list mailing list