473,654 Members | 3,109 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Python embedded interpreter: how to initialize the interpreter ?

Hello,

I've written a C embedded application. I want to open a python gui
application in my C program but when I do :

PyRun_String( "import gui.py", file_input, pDictionary, pDictionary );

the interpreter emits an error: tkinter module not defined

What script must I load to initialize the embedded python interpreter
so as I have the same modules in the python command line and in the
python embedded interpreter ? /usr/lib/python2.4/*.py ??

Yann COLLETTE

Dec 31 '06 #1
3 1987
At Sunday 31/12/2006 10:55, yc*****@freesur f.fr wrote:
>I've written a C embedded application. I want to open a python gui
application in my C program but when I do :

PyRun_String ( "import gui.py", file_input, pDictionary, pDictionary );

the interpreter emits an error: tkinter module not defined
Does it work if you try it from the interpreter?
--
Gabriel Genellina
Softlab SRL


_______________ _______________ _______________ _____
Preguntá. Respondé. Descubrí.
Todo lo que querías saber, y lo que ni imaginabas,
está en Yahoo! Respuestas (Beta).
¡Probalo ya!
http://www.yahoo.com.ar/respuestas

Jan 2 '07 #2
the interpreter emits an error: tkinter module not defined

Capitalize the 't', in Tkinter, its case sensitive.

Jan 2 '07 #3
yc*****@freesur f.fr wrote:
Hello,

I've written a C embedded application. I want to open a python gui
application in my C program but when I do :

PyRun_String( "import gui.py", file_input, pDictionary, pDictionary );

the interpreter emits an error: tkinter module not defined

What script must I load to initialize the embedded python interpreter
so as I have the same modules in the python command line and in the
python embedded interpreter ? /usr/lib/python2.4/*.py ??

Yann COLLETTE
Did you call the Py_Initialize() function before trying to execute that
statement? Note also that you might have to Py_SetProgramNa me(somepath)
before calling Py_Initialize() . See the documentation for details:
http://docs.python.org/ext/embedding.html
http://docs.python.org/api/embedding.html

Hope this helps,
Ziga

Jan 3 '07 #4

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

Similar topics

0
1990
by: vincent Salaun | last post by:
hi all, here's my problem : I've embedded a python interpreter in our java application (based on the NetBeans palteforrm) using the Jython API : http://www.jython.org/docs/javadoc/index.html So, i've used the PythonInterpreter class to instanciate an interpreter and to integrate it but the its environnement doesn't seem to be the
0
1375
by: Gregory Lielens | last post by:
Hello all, I am not sure this is the correct list to ask as my problem is really related to python low level implementation, but as I do not have found a python.dev list, here it is :-) We are curently developing python bindings to make a MPI parallel application (Finite element solver) script driven. I have written a main interpreter, able to execute scripts or interractive commands,in // , based on the following techniques:
2
1869
by: Charlie DeTar | last post by:
So, I have an amazing, functioning foobar class that embeds python. Only trouble is, I want to be able to have multiple foobar objects at once, each with their own interpreters, stdouts, and stderrs. My initialization of the python interpreter in the class "x" is as follows: if (!Py_IsInitialized()) { PyEval_InitThreads(); Py_Initialize(); }
1
2904
by: Donnie Leen | last post by:
I wrote a program embbed boost.python, each thread running a sub-interpreter, i made a module implement by boost.python, and i wish this module imported in each sub-interpreter, i find that the module could initialize only once, otherwise the boost.python will throw a exception said that something already registered; second conversion method ignored. So I try another way, initialize and import the module in one interpreter such as the main...
0
1053
by: PixelDust1 | last post by:
Hi guys, I am pretty new to Python and to embedding it in C. Here is what I am trying to accomplish: I have a C program that accepts user input, which can be a Python script which includes functions defined by the user line by line as typed in. Let me show the code that I have: #include "Python.h"
34
6404
by: Ville Voipio | last post by:
I would need to make some high-reliability software running on Linux in an embedded system. Performance (or lack of it) is not an issue, reliability is. The piece of software is rather simple, probably a few hundred lines of code in Python. There is a need to interact with network using the socket module, and then probably a need to do something hardware- related which will get its own driver written in C.
5
3216
by: wahn | last post by:
Hi, Here is a problem I came across and need some help with. I developed a little Python script with some classes which runs standalone and communicates with a database via sockets. So far everything works fine. I also successfully embedded the Python interpreter into a plugin for a commercial 3D package (in this case Houdini - http://www.sidefx.com/ - using the HDK). I can use the interpreter to run Python commands and get values back...
0
1204
by: Simon Eves | last post by:
I am trying to write a Python module to embed the functionality of Maya (the 3D modelling and animation application from Autodesk, formerly Alias) for doing scripted scene manipulation and rendering processes in Python. I am aware of the CGKit project, which does this and a lot more, but it is over-complex for our needs, and also does not work in the context of a pure command-line Python script, only as an alternative scripting language...
4
2824
by: Chris8Boyd | last post by:
I am embedding Python in a MSVC++ (2005) application. The application creates some environment and then launches a Python script that will call some functions exported from the MSVC++ application. I want to be able to debug the Python script by using a debug server, like Winpdb (winpdb.org). I use ActivePython 2.5.2.2, Microsoft Visual Studio 2005, and Winpdb 1.3.8.
0
8372
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8285
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8814
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8706
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8591
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7304
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6160
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5621
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4293
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.