question

DuanePerry-8743 avatar image
0 Votes"
DuanePerry-8743 asked DuanePerry-8743 commented

Run a python module from C++

I am trying to run a VS python file from VS C++. The following ... PyObject* pName, * pModule,.... pName = PyUnicode_FromString("<filename>.py"); pModule = PyImport_Import(pName); .... Py_Finalize(); The pModule is always NULL. pName have values. I am using Python 3.7. The Python application runs fine. When I try to call it from the C++ app, I get NULL. Suggestions?

c++
· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

I think people will appreciate it if you format the code using the code formatter. I believe that you simply need to indent the code to get it formatted as code. Or use the icon that has the ones and zeros. Also, what does run and call mean? How do you run/call the Python code?

0 Votes 0 ·
  PyObject* pName, * pModule,.... 
 pName = PyUnicode_FromString("<filename>.py"); 
 pModule = PyImport_Import(pName);
    
  ...
  Py_Finalize(); 


The pModule is always NULL. pName have values. I am using Python 3.7. The Python application runs fine in VS. When I use the above code in VS C++, it compiles and runs but as I said, the pModule is NULL.

0 Votes 0 ·

0 Answers