0

Essentially, I want to do this:

#include <Python.h>
int main(int argc, char *argv[]) {
Py_SetProgramName(argv[0]);
Py_Initialize();
PyRun_SimpleString("from time import time, ctime\n"
                 "print 'Today is', ctime(time())\n");
Py_Finalize();
return 0;
}

I successfully got my C code to include Python.h by instructing Eclipse to "include" the folder

C:\Users\Thomas\AppData\Local\Enthought\Canopy\App\appdata\canopy-1.5.5.3123.win-x86_64\includes

which contains Python.h

My understanding is that, in order to successfully implement Python in C, I also have to link Eclipse to the Python library (provide the path to the library's directory and provide the name of the library).

I know how to do this. However, I do not know where the Python library is located in enthought canopy. (I've spent a long time looking)

In a similar question I have Python on my Ubuntu system, but gcc can't find Python.h , someone commented

Pass -I /home/username/python/include to gcc when compiling to make it aware of Python.h. Pass -L /home/username/python/lib and -lpython2.7 when linking."

If I'm running python on canopy, what do I use for the -L and -l arguments?

Thanks, and let me know if I need to clarify anything. (I'm new to C and a relatively inexperienced programmer)

Community
  • 1
  • 1
Mithrandir
  • 101
  • 1
  • First place to look is for `C:\Users\Thomas\AppData\Local\Enthought\Canopy\App\appdata\canopy-1.5.5.3123.win-x86_64\lib`, and see if you find your Python (dynamic) library there. The *directory* would be then be the value for the `-L` option, while `-l` depends on Python version (`-lpython2.7` as above, or -lpython3.5`, for example); the library name should make that obvious. –  Sep 04 '16 at 21:59
  • First step even before that would be to install the current version of Canopy, see https://support.enthought.com/hc/en-us/articles/204469570-Canopy-shows-no-updates-available-reinstalling-from-the-website. Or even better, if you can wait a few weeks for Canopy 1.8.0, the User Python installation will have a simpler structure -- single environment rather than layered virtual environments. – Jonathan March Sep 05 '16 at 01:59

0 Answers0