Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > C/C++
You last visited: Today at 10:49

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



[Problem] Embedding Boost.Python as an interpreter

Discussion on [Problem] Embedding Boost.Python as an interpreter within the C/C++ forum part of the Coders Den category.

Reply
 
Old   #1
 
NikM's Avatar
 
elite*gold: 0
Join Date: Aug 2010
Posts: 972
Received Thanks: 1,583
[Problem] Embedding Boost.Python as an interpreter

Hi there
Im trying around with boost.python because i want to embed a pythoninterpreter to a program.
I already searched for good examples that show the usage but everything i find isnt very informative or just doesnt really work.
Running a simple script doesnt even work .

Code:
int main (void)
{
	Py_Initialize();

	boost::python::object main_module = boost::python::import("__main__");
	boost::python::object main_namespace = main_module.attr("__dict__");

	boost::python::exec("print ('Hello World')", main_namespace);
	boost::python::exec("print ('Hello World'[3:5])", main_namespace);
	boost::python::exec("print ('.'.join(['1','2','3']))", main_namespace);
	
	boost::python::exec_file("test.py", main_namespace, main_namespace); //<- bad boy :(

	return (0);
}
test.py
Code:
print ("Hi")
I would be very kind if someone with some boost.python experience could help me
NikM is offline  
Old 06/11/2014, 02:25   #2



 
+Yazzn's Avatar
 
elite*gold: 420
Join Date: Jan 2012
Posts: 1,082
Received Thanks: 1,000
Versuch mal den absoluten Pfad anzugeben.
+Yazzn is offline  
Reply


Similar Threads Similar Threads
Metin2 C++ Python embedding?
04/07/2014 - Metin2 - 1 Replies
Hi, i am making a metin2 bot, i used write memory and asm, but my friend said me i can do this without asm, just using Python Embedding, like the client is sending the function.. How can i do this? Someone's got an example code? Thanks in advance!
[Python]Embedding code in C++
12/17/2013 - Metin2 - 3 Replies
Hey Leute, ich hab lange aufgehört das zu machen und wollte wieder anfangen. Erfahrungen mit C++ habe ich, aber jedes Mal, wenn ich versuche Code mit PyRun_SimpleString(string s); auszuführen, krieg ich nen Error geworfen. Code: Module Name: C:\Program Files (x86)\Metin2\metin2client.bin Time Stamp: 0x5272224d - (null)
Problem/bug with embedding Youtube videos
11/24/2013 - Main - 6 Replies
#RESOLVED
[Problem] ELF interpreter /libexec/ld-elf.so.d not found
04/11/2012 - Metin2 Private Server - 3 Replies
Fehler meldung ist ELF interpreter /libexec/ld-elf.so.d not found Real Server Log Offmysql_real_connect: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) failed, retrying in 5 secondsAbort trap ELF interpreter /libexec/ld-elf.so.d not found
Python Problem.
10/29/2011 - Metin2 Private Server - 4 Replies
Hey Leute. Ich wollte gerade Python auf Freebsd 8.2 installieren nach dem Tut. http://www.elitepvpers.com/forum/metin2-pserver-g uides-strategies/937110-how2-python-f-r-alles.html Nach make install clean kommt ein Fenster ich gehe auf Close doch nun kommt. Horny# cd /usr/ports/lang/python Horny# make install clean ===> Installing for python-2.7,2 ===> python-2.7,2 depends on file: /usr/local/bin/python2.7 - not found



All times are GMT +1. The time now is 10:50.


Powered by vBulletin®
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2025 elitepvpers All Rights Reserved.