[docs] Embedding Python in Another Application tutorial problem

Ibarra, Jesse jibarra4 at live.nmhu.edu
Fri May 31 19:00:25 EDT 2019


Hi,
I am working on CentOS7

I am trying the 1.1 Very High Level Embedding

I am using
Python 3.7.3 (default, Mar 27 2019, 22:11:17)
[GCC 7.3.0] :: Anaconda, Inc. on linux


I created a file by pasting the tutorial code into original.c

#define PY_SSIZE_T_CLEAN
#include <Python.h>

int
main(int argc, char *argv[])
{
    wchar_t *program = Py_DecodeLocale(argv[0], NULL);
    if (program == NULL) {
        fprintf(stderr, "Fatal error: cannot decode argv[0]\n");
        exit(1);
    }
    Py_SetProgramName(program);  /* optional but recommended */
    Py_Initialize();
    PyRun_SimpleString("from time import time,ctime\n"
                       "print('Today is', ctime(time()))\n");
    if (Py_FinalizeEx() < 0) {
        exit(120);
    }
    PyMem_RawFree(program);
    return 0;
}

After executing:

gcc -o original original.c

original.c:2:20: fatal error: Python.h: No such file or directory

 #include <Python.h>
                    ^
compilation terminated.

What am I doing wrong? Is the tutorial complete?

Thanks,

Jesse




-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/docs/attachments/20190531/aaf0f9a8/attachment.html>


More information about the docs mailing list