Running compiled Python files

S

Shankar

Hello,

I am trying to run compiled Python files (*.pyc and *.pyo) using Python C
API.

I am using the method PyRun_FileFlags() for this purpose.

The code snippet is as follows:-

PyCompilerFlags myFlags;
myFlags.cf_flags=1; // I tried all values 0, 1 and 2
PyRun_FileFlags(script, file, Py_file_input, globals, locals, &myFlags);

But unfortunately I get the following exception:-
"DeprecationWarning: Non-ASCII character '\xf2' in file E:\test.pyc on line
1, but no encoding declared; see http://www.python.org/peps/pep-0263.html
for details"

When I run the .py file, then things work fine.
The .py file contains only one statement,
print "Hello World"

Which Python C API should I use to run compiled Python files(*.pyc and
*.pyo) in the scenario where the source file (*.py) is not present.

Thanks in advance,
Regards,
skn
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
473,767
Messages
2,569,571
Members
45,045
Latest member
DRCM

Latest Threads

Top