Compiling Freeling for Python on Mac OS 10.11

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

Hi,

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.so 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: *** [_freeling.so] 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:
/Library/Frameworks/Python.framework/Versions/3.5/bin/python3.5
But I got the same problem.

I have seen in this post (http://nlp.lsi.upc.edu/freeling-old/index.php?option=com_simpleboard&It…) 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.
TomB

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.
TomB

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