sys.argv not found 
Author Message
 sys.argv not found

Hi all,

I'm writing a python program that uses VRUT (OpenGL application), but I
seem to lose the sys.argv list whenever I run VRUT.  For example,
vrut.go() starts VRUT.  I call it after I ask for sys.argv, but somehow
it begins to run and in the display window gives an AttributeError for
argv.

I'm not quite understanding the logic of the order python is doing (why
it would call the vrut command before the sys.argv).  I tried wrapping
the vrut.go in a function, and calling that function instead to no
avail- same problem.  Sending in the wrong number of arguments however
will generate an "IndexError: list index out of range".

                  --Fen Zhao

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)



Sun, 04 Jan 2004 21:59:08 GMT  
 sys.argv not found


Quote:
> Hi all,

> I'm writing a python program that uses VRUT (OpenGL application), but I
> seem to lose the sys.argv list whenever I run VRUT.  For example,
> vrut.go() starts VRUT.  I call it after I ask for sys.argv, but somehow
> it begins to run and in the display window gives an AttributeError for
> argv.

> I'm not quite understanding the logic of the order python is doing (why
> it would call the vrut command before the sys.argv).  I tried wrapping
> the vrut.go in a function, and calling that function instead to no
> avail- same problem.  Sending in the wrong number of arguments however
> will generate an "IndexError: list index out of range".

>                   --Fen Zhao

> 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)

First, can we assume you have included an "import sys" above the code you
quote?

You should:

a) Make sure you incude the exact error traceback with postings like this,
so we can see more nearly where the problem might be occurring; and

b) Scatter "print" statements to give you confidence that your logic is
indeed being executed as you expect, in the sequence you expect.

I have an idea that vrut.go() might be looking at sys.argv itself, but there
isn't really sufficient data to *know* quite what's going wrong. Your
assumptions appear reasonable, but I think your code *is* being executed in
the order you expect.

Good luck
 Steve
--
http://www.holdenweb.com/



Sun, 04 Jan 2004 22:51:18 GMT  
 sys.argv not found

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

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

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.

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.

                                        --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

     import vrut
     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)

Quote:

> First, can we assume you have included an "import sys" above the code you
> quote?

> You should:

> a) Make sure you incude the exact error traceback with postings like this,
> so we can see more nearly where the problem might be occurring; and

> b) Scatter "print" statements to give you confidence that your logic is
> indeed being executed as you expect, in the sequence you expect.

> I have an idea that vrut.go() might be looking at sys.argv itself, but there
> isn't really sufficient data to *know* quite what's going wrong. Your
> assumptions appear reasonable, but I think your code *is* being executed in
> the order you expect.

> Good luck
>  Steve
> --
> http://www.holdenweb.com/



Mon, 05 Jan 2004 00:01:06 GMT  
 sys.argv not found


Quote:

> I've tried putting a print statement right after I import sys.  I have the
same
> error as before:

****************************************************************************
**
Quote:

>      * WINVRUT 2.4a  Copyright 1995-2001  University of California, Santa
>      Barbara *
>      *                                    Massachusetts Institute of
>      Technology   *

****************************************************************************
**
Quote:

>      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...

Quote:
> 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?

Quote:
> 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?

Quote:
> 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 :-)

Quote:

>                                         --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.

Quote:
>      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.

Quote:
>      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)


> [ 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/



Mon, 05 Jan 2004 00:30:22 GMT  
 sys.argv not found

Perhaps you have another module sys.py somewhere in your path.  Try this
from the interpreter:

Quote:
>>> import sys
>>> sys

<module 'sys' (built-in)>

If this gives you a module name with a file path, you may want to try
moving that file out of the way.

Alex.



Mon, 05 Jan 2004 01:32:45 GMT  
 sys.argv not found
Fiddling with the script some more, it seems like Vrut somehow runs the script
again when vrut.go() is called.  I placed print statements all throughout the
code, which shows up in the interactive window  until vrut.go() is called.  Then
in the vrut window, it gives the Attribute Error.   I'm going to have to muck
through the vrut code itself to see what's going on.

            Thanks for everyone's help!
                Fen

Quote:



> > 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)


> > [ 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/



Mon, 05 Jan 2004 02:55:39 GMT  
 sys.argv not found
It seems that one of the imported modules deletes sys.argv.
Suggestion: import sys at the top of your script, then make immediately the
variable assignements.

Levi


Quote:

>Fiddling with the script some more, it seems like Vrut somehow runs the script
>again when vrut.go() is called.  I placed print statements all throughout the
>code, which shows up in the interactive window  until vrut.go() is called.  Then
>in the vrut window, it gives the Attribute Error.   I'm going to have to muck
>through the vrut code itself to see what's going on.

>            Thanks for everyone's help!
>                Fen




>> > 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)


>> > [ 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/



Mon, 05 Jan 2004 04:13:16 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. sys.argv in Python 2.0 does not work?

2. Chosing between sys.argv and sys.stdin

3. understanding sys.argv[]

4. sys module - argv, but no argc ??

5. sys.argv and while loop

6. catch empty sys.argv

7. ?sys.argv values more literally?

8. Win32 problems: Popen3 and sys.argv[0]

9. Sys.argv

10. sys.argv attribute error

11. Specifiying a module from sys.argv?

12. assignment to sys.argv[0]

 

 
Powered by phpBB® Forum Software