473,378 Members | 1,134 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

PyRun_SimpleString no sys.argv[0]

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

Dec 6 '06 #1
2 5927
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
Dec 7 '06 #2
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
Dec 7 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Link | last post by:
Hi, Have anyone know how to import the DLL in C program? Actually, I have used the statement 'PyRun_SimpleString' to import .PY, Such as, r = PyRun_SimpleString("import os"); It's be...
3
by: Bill Orcutt | last post by:
Having seen the number of lost souls asking questions about embedding Python in the archives of this group, I hesitate to add myself to their number, but I've hit a problem I can't quite get my...
10
by: Robin Sanderson | last post by:
Sorry in advance if this is a stupid question - I am new to C++. In the process of converting program to be run from the command line into a function to be run from another program I noticed...
28
by: Charles Sullivan | last post by:
I'm working on a program which has a "tree" of command line arguments, i.e., myprogram level1 ]] such that there can be more than one level2 argument for each level1 argument and more than one...
22
by: Joe Smith | last post by:
It is nothing short of embarrassing to feel the need to ask for help on this. I can't see how I would make the main control for this. What I want is a for loop and a test condition. And while I...
4
by: interec | last post by:
Hi Folks, I am writing a c++ program on redhat linux using main(int argc, wchar_t *argv). $LANG on console is set to "en_US.UTF-8". g++ compiler version is 3.4.6. Q1. what is the encoding of...
0
by: iwl | last post by:
Hi, it seems like I can't trace scripts run by PyRun_SimpleString(): a=0 def test(frame, event, arg): global a a+=1 import sys
11
by: vicky | last post by:
hi all, please tell me with example, how the *argv point to the the no of strings.
3
by: ShambhuHubli | last post by:
Hi all!! .. I am New member to this group. And also new to C/PYTHON API coding. I am trying to have two way communication i,e i am calling from python to C and then from C to python. I have no...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.