Embedding (PyRun_SimpleFile)
Gordon McMillan
gmcm at hypernet.com
Wed Aug 2 12:47:50 EDT 2000
nick_knight at my-deja.com wrote:
>I am trying to use the following code ( on a windows platform)
[snip]
>int main(int argc, char* argv[])
>{
> char *filename = "e:\\downloads\\python\\testbed\\test.py";
> Py_Initialize(); //Required
>
> FILE *OurFile = fopen(filename,"rb");
> PyRun_SimpleFile(OurFile,filename);
> //PyRun_SimpleString("print 'Hello'");
> return 0;
>}
>
>- where thr file test.py contains
>print "Hello"
>
>every time I run the program ,
>
>'import exceptions' failed; use -v for traceback
>Warning! Falling back to string-based exceptions
>'import site' failed; use -v for traceback
Python can't figure out what sys.path should be.
>gets printed out to stdio, also when the program enters
>PyRun_SimpleFile MSVC comes up with a unhandled exeption
Since you can't be bothered to tell us what the exception is, I'll guess
that you're not using the same c runtime Python is, so when you pass that
FILE * from your code to Python, msvcrt.dll (which is what Python uses)
doesn't like it.
-Gordon
More information about the Python-list
mailing list