Importing Problem on Windows

Peter Otten __peter__ at
Tue Jan 11 16:23:34 CET 2005

brolewis wrote:

> I have a directory that has two files in it:
> imports a function from and uses it to parse out the
> needed information. On Linux, the following code works without a
> problem:
>, line 1:
> from parser import regexsearch
> However, when I run the same command in Windows, I get the following
> error:
> ImportError: cannot import name regexsearch
> Any suggestions on why this would work on Linux but not on Windows?

This has nothing to do with Linux vs. Windows. Depending on sys.path and
your current working directory either your own or the
module in the library is imported.
If you want to play it safe, rename your to or another
name that is not already used by the standard library and avoid the
confusion between the two modules. If you do that, don't forget to delete
the compiled module parser.pyc or parser.pyo, too.


More information about the Python-list mailing list