Need help with PyRun_SimpleFile
Michael P. Reilly
arcege at shore.net
Wed Sep 1 10:23:10 EDT 1999
Scott Shillcock <shillcoc at mry.rbd.com> wrote:
: Hello,
: Here is my very simple program:
: #include <iostream.h>
: #include "Python.h"
: void
: main (int argc, char **argv) {
: Py_Initialize ();
: FILE *fp = fopen ("test.py", "r+");
: cerr << "Before PyRun_SimpleFile" << endl;
: PyRun_SimpleFile (fp, "test.py");
: cerr << "After PyRun_SimpleFile" << endl;
: Py_Exit(0);
: }
: I can compile this into an exe file. I also created a very simple
: test.py file that just prints one line of text. When I run my program it
: crashes on the PyRun_SimpleFile() every time. I get the first cerr but
: not the second.
: What I am doing wrong? I have tried as many variations on this at I
: could think of, all with the same result.
: Thanks,
: Scott
Hi Scott,
I've complied the same program and created an empty "test.py" file and
it ran with no errors. What is the error message (output), error code
("echo $?" (sh) or "echo $status" (csh) or "echo %ERRORLEVEL%"
(Windows)) and what are the contents of the "test.py" file? If you are
on a Windows machine, did you run the executable from cmd.exe? Can you
import the file into Python itself? How about trying:
$ python >>> execfile("test.py")
Also, what OS and compiler and version of Python where you using?
("python -c 'import sys; print sys.version'") Giving that info might
help people with answering your question.
-Arcege
More information about the Python-list
mailing list