Compiling Freeling for Python on Mac OS 10.11

Submitted by TomB on Sat, 04/09/2016 - 13:28


I am trying to compile the API for Python in MacOS.
After issuing 'make' in APIs/python, I got this error:

$ make
g++ -dynamiclib -o freeling_pythonAPI.cxx -lpython3.5 -lfreeling -I/opt/local/include -L/opt/local/lib -I/Library/frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages -fPIC
freeling_pythonAPI.cxx:171:11: fatal error: 'Python.h' file not found
# include < Python.h >
1 error generated.
make: *** [] Error 1

I have doubts for assigning correctly the variable PYTHONDIR. I am working with PyCharm, and with the version python 3.5.

The previous value for the PYTHONDIR variable corresponds to the directory where the packages are installed.
I have also tried with the directory where the interpreter is hosted:
But I got the same problem.

I have seen in this post (…) the suggestion to assign the value usr/include/python3.1 to PYTHONDIR. However, the only directory I had with a similar name is /usr/include/python2.7. In this directory there is a file named 'Python.h'.

I do not know if I should assign /usr/include/python2.7 for PYTHONDIR, as the interpreter I work with is version 3.5.

Any help will be very much appreciated.

Please check the README file in the APIs/python directory:

`PYTHONDIR: must be the libraries directory of your local python installation --e.g /usr/include/python3.4`

So, if you have python 3.5, you should have a directory like /usr/include/python3.5

If you don't have it, you need to do what the README says:

`Make sure python development headers are installed (e.g. package python3-dev or the like)`

Thanks, Lluis. You are right: my problem is the installation of python development headers. But I have many problems with this question for Mac. I do not find a clear guide for installing them.
So, I will work with Freeling through the command line.

Thanks again for your time.

I am afraid there is no installation guide for Mac, but it should not be difficult to replicate the Linux steps in a mac:
* Install python headers (probably there is a macports package for it)
* Set the right paths in the Makefile
* Maybe adapt the commands in the make file (e.g. replace g++ with clang, or adapt compilation options)
* execute the Makefile