Importing Problem on Windows
John Machin
sjmachin at lexicon.net
Tue Jan 11 18:06:06 EST 2005
brolewis wrote:
> I have a directory that has two files in it:
>
> parse.py
> parser.py
>
> parse.py imports a function from parser.py and uses it to parse out
the
> needed information. On Linux, the following code works without a
> problem:
>
> parse.py, 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 yourscript.py
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