Importing Problem on Windows

John Machin sjmachin at
Tue Jan 11 18:08:06 EST 2005

brolewis wrote:
> I have a directory that has two files in it:
> imports a function from and uses it to parse out
> 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?

Hint for the future: use the -v argument (python -v
yourarg1 etc) to see where modules are being imported from.

Example (I don't have a module named parser anywhere):

python -v
[big snip]
>>> from parser import regexsearch
import parser # builtin               <<<<==== aha!
Traceback (most recent call last):
File "<stdin>", line 1, in ?
ImportError: cannot import name regexsearch

More information about the Python-list mailing list