sys.argv not found

Steve Holden sholden at holdenweb.com
Wed Jul 18 12:30:22 EDT 2001


"Man Vehicle Laboratory" <FenZhao at mit.edu> wrote in message
news:3B55B2C2.74A8FB3D at mit.edu...
>
> I've tried putting a print statement right after I import sys.  I have the
same
> error as before:
>
>
>
****************************************************************************
**
>
>      * WINVRUT 2.4a  Copyright 1995-2001  University of California, Santa
>      Barbara *
>      *                                    Massachusetts Institute of
>      Technology   *
>
****************************************************************************
**
>
>      VRUT  2.4a
>      voicekey                        Voicekey 0.9
>      serialthrustmaster              Serial thrustmaster 1.0
>      avstu                           AvatarStudio 1.1
>      Traceback (most recent call last):
>        File "<string>", line 1, in ?
>        File "N:\FenZhao\E3_sid_data\e3_sid_data2.py", line 61, in ?
>          print sys.argv
>      AttributeError: argv
>
Well, this traceback looks very suspicious. I assume that the file you are
taking about is indeed e3_sid_data2.py?  Maybe not ... it is quite weird
that sys appears to have no argv attribute. I can only conclude that perhaps
some other portion of your code assigns to sys? But you say below this is
NOT the case. Aaarrgghh...

> The error I get from vrut is from my code looking at argv, not vrut (error
> message w/out print statement:
>
> Traceback (most recent call last):
>   File "<string>", line 1, in ?
>   File "N:\FenZhao\E3_sid_data\e3_sid_data2.py", line 62, in ?
>     mode=string.atoi(sys.argv[1])
> AttributeError: argv
>
The first line of the tracebacks implies that some code is being executed
from a strng variable. If none of your code does anything like that (uses
eval/exec, let's say) then the obvious suspect is the vrut module...

Your module doesn't by any chance import itself, does it?

> So whatever my first operation is dealing with sys.argv, there's an
attribute
> error with argv)
>
> What confuses me is that this error is displayed in the VRUT window; VRUT
opens
> two windows, a display window that shows the 3D VR scene, and a text
window that
> will display print statements and error messages from python.  Logically,
if
> argv can't be found, an error message will end the program before vrut
ever gets
> started.
>
Oh. Is it possible that importing the vrut module modifies
sys.stdout/sys.stderr, leaving something weird in place before the vrut.go()
call creates the windows?

> I've also tried importing vrut after looking at sys.argv in case vrut does
> something funky in it's initialization/import.  Same problem.  Yet
commenting
> out the vrut.go() command, and the sys.argv is fine.

OK, so what you are telling us is that the presence of a function call you
have not yet executed is somehow affecting the sys module's namespace. That
sounds pretty funky to me, and frankly I'm beginning to wonder whether you
have programmed a time machine :-)

>
>                                         --Fen
>
> PS. I hope this helps:  all of my code up to the call to vrut (minus
> comments)...  there's not much there, can't figure out what's making it
work
> improperly.  None of the modules that I wrote and imported do anything
with sys
>
I can understand your confusion. I hope the rest of the list will feel free
to dive in with suggestions about what's wrong! :-0
>

Put "import sys; print sys.argv" here to make sure your program does indeed
see the correct value for the argument list.

>      import vrut

Put "import sys; print sys.argv" here too, to verify that the import
statement makes no changes to sys.
If you see output from the first print bu not the second then the module is
indeed doing something funky.

>      import sid
>
>
>      import string
>      import math
>      import time
>
>
>      import speeds
>      import e3_dataAn
>      import sys
>
>      mode=string.atoi(sys.argv[1])
>      ARGFILE_stim=sys.argv[2]
>      ARGFILE_calib=sys.argv[3]
>      OUTFILE=sys.argv[4]
>      SUMFILE=sys.argv[5]
>      sidOutfile=sys.argv[6]
>      VECTION_DURATION=string.atoi(sys.argv[7])
>      path=sys.argv[8]
>
>      vrut.go(vrut.NICE)
>
>
>
> Steve Holden wrote:
> [ various apparently irrelevant things ]

I'm currently betting that a recursive import is somehow messing things up.
Otherwise I'm a little stumped, and we'll have to proceed with debugging
step by step.

regards
 Steve
--
http://www.holdenweb.com/








More information about the Python-list mailing list