0

I have a problem that involves Jupyter Notebook with Anaconda's implementation of Cython (Version 4.3.1). A code appears to be converted to .c by Cython as it should be, but the gcc compiler is giving the error message "fatal error: python4.3.1/Python.h: No such file or directory (\n) compilation terminated."

This question has been asked before, and thus I understand that the problem has to do with gcc's referencing of headings and library paths in the .c file that is being compiled. In Linux (often Ubuntu), this question has been answered with reference to installation suggestions of python3-dev. Such an answer can be found @ How to use Cython to compile Python 3 into C. However, for Windows (my OS), it appears that this reference is unnecessary because the file Python.h is already installed to my computer (@ How to get python-dev for windows?).

I have not seen an answer that involves Windows operation system and potentially, if this matters (I am able to successfully get an uncompiled .c file), reference to specifics of Anaconda's implementation of Cython. It seems that a solution to my problem may involve some sort of path referencing to the Python.h library's C:\Users\Josh\include file path when compiling the C code in the gcc command window.

Small Request: I am new to command prompts. Therefore, when referencing command inputs, mentioning both what to type AND what interface to type it in (Ex. 'Anaconda Prompt') would be very helpful.

Thanks! -joshm

Footnote: Understandably, the easiest answer may be to switch to a virtual machine in Linux and/or to implement some other Python package, but I wish to stay in Windows (regrettably, a crutch) and Jupyter Notebooks (where scientific computing is comfortable, and files are easily written and read) if possible. The goal of this conversion is to run a program implementing Monte Carlo simulation over MANY loops in a compiled .c form to optimize its speed for generating data in a project. (I welcome other suggestions related to attaining greater speed optimization).

joshm
  • 1
  • The .c file was produced by using distutils.core << setup AND Cython.Build << cythonize library imports within Jupyter Notebook. – joshm May 22 '17 at 22:10
  • My diagnosis trusts that the Anaconda writing algorithm that is correct, and simply gcc's read path that must be changed. – joshm May 23 '17 at 06:15
  • You can pass an include path to a `%%cython` magic. Start your cell with `%%cython -I/path/to/Python.h`. – Pierre de Buyl May 23 '17 at 13:40
  • https://stackoverflow.com/questions/5105482/compile-main-python-program-using-cython solved my problem. Thank you for the response Pierre de Buyl! – joshm May 24 '17 at 15:43
  • https://stackoverflow.com/questions/5105482/compile-main-python-program-using-cython solved my problem. Also, I moved to Linux. – joshm May 24 '17 at 15:45

0 Answers0