I want to use the Python Libray from my C++ program.
The Python Libray is no GUI. How can I mix C++ and
Python?
One way is to run PY library as an independent process.
Another way is to start PY as a C++ thread.
The third way is to run Python engine as part of the C++.
Which way is better?
No intention to access all the Python's code but only
access APIs of a module. 11 6627
Chang LI wrote: I want to use the Python Libray from my C++ program. The Python Libray is no GUI. How can I mix C++ and Python?
One way is to run PY library as an independent process. Another way is to start PY as a C++ thread. The third way is to run Python engine as part of the C++. Which way is better?
No intention to access all the Python's code but only access APIs of a module.
Try Elmer. http://elmer.sf.net
--
Robert Kern rk***@ucsd.edu
"In the fields of hell where the grass grows high
Are the graves of dreams allowed to die."
-- Richard Harter
Chang LI wrote: I want to use the Python Libray from my C++ program. The Python Libray is no GUI. How can I mix C++ and Python?
One way is to run PY library as an independent process. Another way is to start PY as a C++ thread. The third way is to run Python engine as part of the C++. Which way is better?
No intention to access all the Python's code but only access APIs of a module.
Try boost.python and SWIG?
(boost.sourceforge.net, swig.sourceforge.net)
Both provide a interface between C/C++ and python
if you want gui under python, you also can try wxpython or pygtk
zhao wrote: Try boost.python and SWIG? (boost.sourceforge.net, swig.sourceforge.net)
Both provide a interface between C/C++ and python if you want gui under python, you also can try wxpython or pygtk
I thought SWIG ported C/C++ libraries to Perl, Python, Ruby, Tcl, etc?
How would you use it to port Python into C/C++?
I think what you're looking for is instruction on how to embed Python in
your C/C++ application.
Chang LI a écrit : I want to use the Python Libray from my C++ program. The Python Libray is no GUI. How can I mix C++ and Python?
One way is to run PY library as an independent process. Another way is to start PY as a C++ thread. The third way is to run Python engine as part of the C++. Which way is better?
No intention to access all the Python's code but only access APIs of a module.
If you just want to access the Python API (or some APIs of modules) you
need to launch the interpreter (in the current thread will be ok) and
then you can access everything ... import modules, create objects, etc.
Pierre
Pierre Barbier de Reuille <pi************@cirad.fr> wrote in message news:<41***********************@news.free.fr>... If you just want to access the Python API (or some APIs of modules) you need to launch the interpreter (in the current thread will be ok) and then you can access everything ... import modules, create objects, etc.
Yes. That is what I want (to launch Python Interpreter from C++ and use it)
Where is the document?
Pierre
"Chris S." <ch*****@NOSPAM.udel.edu> wrote in message news:<ukgpd.12554$Vy.6850@trndny06>... zhao wrote:
Try boost.python and SWIG? (boost.sourceforge.net, swig.sourceforge.net)
Both provide a interface between C/C++ and python if you want gui under python, you also can try wxpython or pygtk I thought SWIG ported C/C++ libraries to Perl, Python, Ruby, Tcl, etc? How would you use it to port Python into C/C++?
SWIG is for Python to use C++. I am searching for in reverse.
I think what you're looking for is instruction on how to embed Python in your C/C++ application.
On Fri, 2004-11-26 at 01:13, Chang LI wrote: Yes. That is what I want (to launch Python Interpreter from C++ and use it) Where is the document? http://docs.python.org/
Check out the C API reference and the embedding tutorial.
--
Craig Ringer
Chang LI wrote: "Chris S." <ch*****@NOSPAM.udel.edu> wrote in message news:<ukgpd.12554$Vy.6850@trndny06>...
zhao wrote:
Try boost.python and SWIG? (boost.sourceforge.net, swig.sourceforge.net)
Both provide a interface between C/C++ and python if you want gui under python, you also can try wxpython or pygtk
I thought SWIG ported C/C++ libraries to Perl, Python, Ruby, Tcl, etc? How would you use it to port Python into C/C++?
SWIG is for Python to use C++. I am searching for in reverse.
Elmer is the reverse of SWIG, and should be easier to use than using the
Python C API itself. Elmer will handle the conversion of types between
Python and C++ and will expose a nice API on the C++ side.
--
Robert Kern rk***@ucsd.edu
"In the fields of hell where the grass grows high
Are the graves of dreams allowed to die."
-- Richard Harter
Robert Kern <rk***@ucsd.edu> wrote in message news:<co**********@news1.ucsd.edu>... Try Elmer.
http://elmer.sf.net
Looks like a perfect match between Python and C++.
Great thanks!
Chang
swig is a interface of C/C++ to python, but not in reverse.
In term of python document, there are extend and embed, and your need
is embed.
below is a short tutorial, maybe helpful: http://tutorials.impereonsoft.com/python/extemb.html
if you work in windows, and you have install pywin32 package, it expose
a com interface of python interpreter,
so you also can use python's script or module in your application by
this interface.
if you use BCB, you can use a VCL component name "Python for Delphi".
Robert Kern <rk***@ucsd.edu> wrote in message news:<co**********@news1.ucsd.edu>... Chang LI wrote: I want to use the Python Libray from my C++ program. The Python Libray is no GUI. How can I mix C++ and Python?
.... (snip) Try Elmer. http://elmer.sf.net
There is also a library called PyCXX at http://cxx.sourceforge.net/.
It's main purpose is to provide a convenient C++ interface to the
Python C API. For example, it takes care of reference counting etc.
Although it's purpose is to write C++ extensions for Python, it should
be fairly easy to use it in reverse. It's a nice lib either way. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Stephen Ferg |
last post by:
I am a very satisfied user of Python and have been for number of
years. I would never willing use another language. I wish all good
things for Python, and that moves me to express some thoughts...
|
by: gyromagnetic |
last post by:
The following url points to an article written by Damian Conway
entitled "Ten Essential Development Practices":
http://www.perl.com/pub/a/2005/07/14/bestpractices.html
Althought the article has...
|
by: Guy Fawkes |
last post by:
Hi,
I was wondering if Python programs always need to include the source code
with the program itself. I'm asking this because I don't want my program to
be open-source and so far all the Python...
|
by: Justin Johnson |
last post by:
Hello,
I'm trying to build Python 2.5.0 on AIX 5.3 using IBM's compiler
(VisualAge C++ Professional / C for AIX Compiler, Version 6). I run
configure and make, but makes fails with undefined...
|
by: Arnaud Delobelle |
last post by:
Hi fellow python enthusiasts.
Having recently acquired a MacBook Pro (Intel Core 2 Duo) which comes
with python2.5, I have been installing some modules that I need (PIL,
psycopg2, PyXML ...).
...
|
by: Con |
last post by:
Hi, I'm gettting a traceback when I attempt to read the MySQLdb docs
after installation on Mac OS X 10.5.2:
BEGIN TRACEBACK:
Traceback (most recent call last):
File "<stdin>", line 1, in...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
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...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
| |