[Tutor] Wrong version of Python being executed
Kent Johnson
kent37 at tds.net
Sun Nov 11 03:16:16 CET 2007
Tony Cappellini wrote:
> When I run this python script, the following exception is thrown,
> implying that it is being executed with Python 2.3
> So I've added this print statement to the main function, which shows
> the logging module is being imported from the Python 2.3 directory
>
> print"\nlogging.__file__ = %s" % logging.__file__
>
> logging.__file__ = C:\Python23\lib\logging\__init__.pyc
>
>
>
> Traceback (most recent call last):
> File "c:\Project\myscript.py", line 584, in
> ?
> main(sys.argv)
> File "c:\Project\myscript.py", line 518, in
> main
> logging.basicConfig(level=config.verbosity,format='%(message)s')
> TypeError: basicConfig() takes no arguments (2 given)
>
>
> The really odd thing is when I bring up the python interpreter at the
> same command prompt where i ran the script above,
> Python 2.5 is invoked, as seen by
>
>
> Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit
> (Intel)] on win32
> Type "help", "copyright", "credits" or "license" for more information.
>>>> import sys
>>>> sys.version
> '2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit (Intel)]'
>
>
> How is it that running a script invokes Python 2.3, but running the
> interpreter without the script invoked Python 2.5?
A couple of possibilities...
Is there a #! line at the start of the script that specifies Python 2.3
(I'm not sure if those work in windows though...)
How do you run the script? If you double-click it, perhaps the file
association with .py files is to Python 2.3?
Conceivably the Python 2.5 module path is incorrect and imports the
wrong module. What happens if you import logging from the interpreter
prompt and print its file? What do you get if you print sys.path from
the interpreter?
HTH,
Kent
More information about the Tutor
mailing list