[Tutor] Weird Try..Except Error

Nikunj.Badjatya at emc.com Nikunj.Badjatya at emc.com
Fri Nov 25 13:42:18 CET 2011


Hi All,

Thanks for the info.
I had Python27 and Python32 both installed togethar.
In Windows the PATH env variable, I had set Python27 exe and lib path.

But When I do
C:\> Python  [PressEnter]
I get 2.7

But when I run 
C:\> script.py  [PressEnter]
The script is running with Python3.2 , thts weird because I have set my Path variable with Pytho27 exe and lib.

Which was causing the problem.

Thanks
Nikunj

-----Original Message-----
From: tutor-bounces+nikunj.badjatya=emc.com at python.org [mailto:tutor-bounces+nikunj.badjatya=emc.com at python.org] On Behalf Of Peter Otten
Sent: Friday, November 25, 2011 5:28 PM
To: tutor at python.org
Subject: Re: [Tutor] Weird Try..Except Error

Nikunj.Badjatya at emc.com wrote:

> Please look at the snippet below.
> When I am running my module its giving me following error.
> Using : Python 2.7, windows Env.
> 
> {{{
> # User defined modules
> try:
>     from scripts import precheck
>     from scripts import input
>     from scripts import validate
>     from scripts import logsetup
>     from scripts.constants import *
> except ImportError, err_msg:                  ==> line 38
>     print("ERROR {0}".format(err_msg))
>     print("INFO  Please verify the presence of above module, and restart
>     the installation") sys.exit(1)
> 
> }}}
> 
> {{{
> Output:
> 
> C:\> install.py -f input.xml
>   File " C:\>install.py", line 38
>     except ImportError, err_msg:
>                       ^
> SyntaxError: invalid syntax
> }}}
> 
> I checked the comma and spacing and didn't find any problem.
> 
> Any idea.?

You are likely mistaken about the Python version you are using. The above 
error will be triggered by Python 3.x which expects

try:
    ...
except ImportError as err_msg:
    ...


_______________________________________________
Tutor maillist  -  Tutor at python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor



More information about the Tutor mailing list