Importing Problem on Windows
sjmachin at lexicon.net
Tue Jan 11 18:06:06 EST 2005
> I have a directory that has two files in it:
> parse.py imports a function from parser.py and uses it to parse out
> needed information. On Linux, the following code works without a
> parse.py, line 1:
> from parser import regexsearch
> However, when I run the same command in Windows, I get the following
> 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):
>>> 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