[C++-sig] Failed to import pyd File When python embed into C++

2013-01-22 Thread salinea

I create a pyd File named "testPyd" with boostPython,and then I import the
testPyd module into "test.py", it works perfect!
But when I embeded the python interpreter into my C++ project and run the
"test.py", it comes out a "ImportErr: no module named testPyd".
It has confused me for two days and I googled for long time,but I can't find
the answer!
Anybody here can help me ?
Thank you!

Here is my test examples: 
The C++ codes to build the *pyd File* is: 
Excute.h 

#ifndef EXCUTE_H_ 
#define EXCUTE_H_ 
#include  

class Excute 
{ 
public: 
Excute(){} 
int getIoReuslt(std::string ioStr); 
int getSignal(); 
}; 
#endif 

Excute.cpp: 
#include "Excute.h" 
#include "Explanation.h" 
#include  

int Excute::getIoReuslt(std::string ioStr) 
{ 
return 1; 
} 

int Excute::getSignal() 
{ 
int i = rand()%2; 
return i; 
} 

BOOST_PYTHON_MODULE(pythonDll) 
{ 
using namespace boost::python; 
class_("Excute", init<>()) 
.def("getIoResult", &Excute::getIoReuslt) 
.def("getSignal", &Excute::getSignal) 
; 
} 
Then a pyd File Named pythonDll is created(pythonDll.pyd), 
Here are the codes in my test.py: 
test.py: 

from pythonDll import* 
h=Excurte() 
print h.getIoResult("a") 
print h.getSignal() 

And this script works perfect in IDLE. 

And then I embed python into my C++ project,Here are the test codes: 
#include  
#include  

int main(int argc, char* argv[]) 
{ 
Py_Initialize(); 
FILE * fp = fopen("$PATH/test.py", "r"); 
if (fp == NULL) 
{ 
return 1; 
} 
PyRun_SimpleString("execfile($PATH/test.py')"); 
Py_Finalize(); 

system("Pause"); 

return 0; 
} 

The result is: 
Traceback (most recent call last): 
  File "", line 1, in  
  File "$PATH/test.py", line 1, in  
from pythonDll import* 
ImportError: No module named pythonDll 
[19228 refs] 



--
View this message in context: 
http://boost.2283326.n4.nabble.com/Failed-to-import-pyd-File-When-python-embed-into-C-tp4641675.html
Sent from the Python - c++-sig mailing list archive at Nabble.com.
___
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig


[C++-sig] How to debug pyd File in Visual Studio???

2013-01-25 Thread salinea
Recently, I build a hybrid system with C++ and python.
First,I encapsulate a class(I can't guarantee the robustness of this
class ) with boost.python which can implement some functions that can not be
implemented by C++, I get a .pyd File in result. 
Second,I embed a python interpreter in c++.
Third, use the embed interpreter to execute a .py File.The .py File
include the module that in .pyd File I created.
Here, the problem comes out! When I start my main project. I can only
debug the problems in my main project, when my main project use the python
interpreter to execute the python interpreter, I can't see what happened in
my pyd File, the whole project collapsed.I know the error is in the pyd
File, and if I set a break point in my resource files of pyd File, either
the project will go to the break point.
   Is there any methods to debug the resource file in this condition!



--
View this message in context: 
http://boost.2283326.n4.nabble.com/How-to-debug-pyd-File-in-Visual-Studio-tp4641746.html
Sent from the Python - c++-sig mailing list archive at Nabble.com.
___
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig