ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> cpp-sig
cpp-sig
[C++-sig] Problem with reinit of Numeric in embedded Python
by Lutz Paelike other posts by this author
Oct 20 2003 8:45AM messages near this date
[C++-sig] Can I import a module in C++ and use in python script ? | [C++-sig] Can I import a module in C++ and use in python script ?
Hi,

i have a problem with a strange error. Maybe somebody has experienced something similar,
or maybe it's a bug of boost i don't know...

The problem is that i embedded python in my application and it works just fine on the first 
time i run it.
But my application itself is a plugin and is loaded and unloaded into the host application.

Now if i load my plugin (works like expexted), unload and load again it doesn't work anymore
.
I guess that something is not properly reinitialised, but stepping through in the debugger
shows that python is correctly unloaded (Py_Finalize is called) and reloaded (Py_Initialize 
is called again).

I can even run python code after the reinit, but it breaks when it comes to this call.

So here are the ingredients:

I get this exception while calling back from python into my c++ code

   File "C:\test_particles.py", line 24, in compute
     baseP = currentField.getPositionAt(basePNum)
ImportError: No module named 'Numeric' or its type 'ArrayType' did not follow the NumPy prot
ocol

---

this is the corresponding c++ method:

	object getFromPython_PointAt(int index){
  		if (pPoints!=NULL) {
			MVectorArray &pp = *pPoints;

			const MVector &p = pp[index];
			return numeric::array( make_tuple(p.x, p.y, p.z) );
		} else {
			throw InitialisationException();
		}
	}

if step trough the corresponding c++ code  when the call from python is made it all works
until the
		return numeric::array( make_tuple(p.x, p.y, p.z) );

is made. So for me looks like a problem of the numeric module of boost.python.
Could this be a bug or did i forgot to initialise numeric somehow ?

Thanks for your help,

Lutz


_______________________________________________
C++-sig mailing list
C++-sig@[...].org
http://mail.python.org/mailman/listinfo/c++-sig

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved