Re: Importing Problem on Windows

2005-01-11 Thread brolewis
I launched the interpreter shell from the same directory in both
Windows and Linux before posting. That's what sent the red flag up for
me.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Importing Problem on Windows

2005-01-11 Thread Peter Otten
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?

This has nothing to do with Linux vs. Windows. Depending on sys.path and
your current working directory either your own parser.py or the parser.py
module in the library is imported.
If you want to play it safe, rename your parser.py to myparser.py 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.

Peter



-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Importing Problem on Windows

2005-01-11 Thread John Machin

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


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Importing Problem on Windows

2005-01-11 Thread John Machin

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


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Importing Problem on Windows

2005-01-10 Thread Grig Gheorghiu
What version of Python are you running on Linux vs. Windows?

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Importing Problem on Windows

2005-01-10 Thread brolewis
Sorry. 2.4 in both locations

-- 
http://mail.python.org/mailman/listinfo/python-list