PyRun_SimpleString no sys.argv[0]

Discussion in 'Python' started by iwl, Dec 6, 2006.

  1. iwl

    iwl Guest

    Hello,

    I'm just starting with Python - would like to embed it in my
    windows-programm as an script-processor. For tests I use easygui some
    easy-wrapper for the py-tck-stuff.

    PyRun_SimpleString("from easygui import *\n");
    PyRun_SimpleString("import sys\n");
    PyRun_SimpleString("msgbox()\n");

    Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "easygui.py", line 148, in msgbox
    reply = buttonbox(message, title, choices)
    File "easygui.py", line 170, in buttonbox
    root = Tk()
    File "C:\Python\Python25\Lib\lib-tk\Tkinter.py", line 1631, in
    __init__
    baseName = os.path.basename(sys.argv[0])
    AttributeError: 'module' object has no attribute 'argv'

    May bee makes some sence that the embedded Interpreter has no argv[0],
    however tk seems not to bee ready for that.
    I try to define some sys.argv[0] myself after I get out how to do that,
    maybee someone other has an better idea until than.
    iwl, Dec 6, 2006
    #1
    1. Advertising

  2. At Wednesday 6/12/2006 12:23, iwl wrote:

    >I'm just starting with Python - would like to embed it in my
    >windows-programm as an script-processor. For tests I use easygui some
    >easy-wrapper for the py-tck-stuff.


    Looks a bit strange for me. If the GUI will be in Python, I think you
    could do things the other way, *extending* your main Python program
    with your own C code, not *embedding* Python inside your main C program.
    I'm not sure if Tk can run without a mainloop.

    Anyway, to answer your actual question:

    >Traceback (most recent call last):
    > File "<string>", line 1, in <module>
    > File "easygui.py", line 148, in msgbox
    > reply = buttonbox(message, title, choices)
    > File "easygui.py", line 170, in buttonbox
    > root = Tk()
    > File "C:\Python\Python25\Lib\lib-tk\Tkinter.py", line 1631, in
    >__init__
    > baseName = os.path.basename(sys.argv[0])
    >AttributeError: 'module' object has no attribute 'argv'
    >
    >May bee makes some sence that the embedded Interpreter has no argv[0],
    >however tk seems not to bee ready for that.
    >I try to define some sys.argv[0] myself after I get out how to do that,
    >maybee someone other has an better idea until than.


    From the Python/C API Reference Manual, section "Embedding Python"
    (that I hope you have already read):
    Py_Initialize() does not set the ``script argument list'' (sys.argv).
    If this variable is needed by Python code that will be executed
    later, it must be set explicitly with a call to PySys_SetArgv(argc,
    argv) subsequent to the call to Py_Initialize().


    --
    Gabriel Genellina
    Softlab SRL

    __________________________________________________
    Correo Yahoo!
    Espacio para todos tus mensajes, antivirus y antispam ¡gratis!
    ¡Abrí tu cuenta ya! - http://correo.yahoo.com.ar
    Gabriel Genellina, Dec 7, 2006
    #2
    1. Advertising

  3. Re: Re: PyRun_SimpleString no sys.argv[0]

    Please keep posting on this list, surely other people can help more than I.

    At Thursday 7/12/2006 06:16, Ingo Wolf wrote:

    > > At Wednesday 6/12/2006 12:23, iwl wrote:
    > >
    > > >I'm just starting with Python - would like to embed it in my
    > > >windows-programm as an script-processor. For tests I use easygui some
    > > >easy-wrapper for the py-tck-stuff.

    > >
    > > Looks a bit strange for me. If the GUI will be in Python, I think you
    > > could do things the other way, *extending* your main Python program
    > > with your own C code, not *embedding* Python inside your main C program.
    > > I'm not sure if Tk can run without a mainloop.
    > >

    >No I have an Borland C++ GUI Windows App and should make it scriptable
    >I tryed using MS ScriptControl first but have only Problems with now I
    >try phyton which also have more posibillities.
    >May bee I find a way to also access my script engine from outside
    >my programm. Open and connecting some kind of terminal for my embedded
    >phyton would also be fine.


    Embedding Python into your app seems fine - but in this case, your
    example (using Tk) is not a good starting point, since python wont
    use a GUI (your App is the GUI).


    --
    Gabriel Genellina
    Softlab SRL

    __________________________________________________
    Correo Yahoo!
    Espacio para todos tus mensajes, antivirus y antispam ¡gratis!
    ¡Abrí tu cuenta ya! - http://correo.yahoo.com.ar
    Gabriel Genellina, Dec 7, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?ISO-8859-1?Q?Thomas_N=FCcker?=

    sys.argv[0] - 'module' object has no attribute 'argv'

    =?ISO-8859-1?Q?Thomas_N=FCcker?=, Jun 30, 2003, in forum: Python
    Replies:
    0
    Views:
    900
    =?ISO-8859-1?Q?Thomas_N=FCcker?=
    Jun 30, 2003
  2. Søren Johansen

    PyRun_SimpleString, PyRun_File

    Søren Johansen, Aug 5, 2003, in forum: Python
    Replies:
    0
    Views:
    868
    Søren Johansen
    Aug 5, 2003
  3. Stavros Tsolakos

    Re: PyRun_SimpleString, PyRun_File

    Stavros Tsolakos, Aug 6, 2003, in forum: Python
    Replies:
    0
    Views:
    468
    Stavros Tsolakos
    Aug 6, 2003
  4. Link
    Replies:
    3
    Views:
    616
    Syver Enstad
    Sep 23, 2003
  5. iwl
    Replies:
    0
    Views:
    329
Loading...

Share This Page