Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Due to the high availability of python code for the rpi, I'm trying to call python functions from Mathematica. I know that pythonika works well on OS X, but I can't compile it on the Raspberry pi.

This is the repository for pythonika:

https://github.com/erocarrera/pythonika

I suspect that I need to change the Makefile.linux to match Raspberry pi settings. But so far I havent been able to succeed.

share|improve this question

I was able to do it. I'll post what I did in case somebody else needs it. So far it works really nice. Just follow the instructions from the repository, and modify the Makefile.linux with the following code, saved as Makefile.linux:

# Set the paths according to your MathLink Developer Kit location.
# (The paths should not contain whitespaces)

MATHEMATICA_INSTALL_DIR = /opt/Wolfram/WolframEngine/10.3
MLINKDIR = ${MATHEMATICA_INSTALL_DIR}/SystemFiles/Links/MathLink/DeveloperKit

SYS = Linux-ARM
CADDSDIR = ${MLINKDIR}/${SYS}/CompilerAdditions

INCDIR = ${CADDSDIR}
LIBDIR = ${CADDSDIR}

MPREP = "${CADDSDIR}/mprep"
MCC = "${CADDSDIR}/mcc"

# Modify the following for Python versions other than 2.6
PYTHON_VERSION_MAJOR = 2
PYTHON_VERSION_MINOR = 7


# Path to the Python includes (modify according to Python version)
#
PYTHONINC = /usr/include/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/


PYTHONIKA = Pythonika
INCLUDES = -I${INCDIR} -I${PYTHONINC}

# libstdc++ and librt are, apparently, needed for correct compilation under Linux
# with libMLi3 statically linked
#
LIBS = -L${LIBDIR} ${LIBDIR}/libML32i4.a -lstdc++ -lrt -lm -pthread -luuid -ldl -lpython${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}


all : Pythonika

Pythonika: ${PYTHONIKA}.o ${PYTHONIKA}tm.o
    ${CC} ${INCLUDES} ${PYTHONIKA}.o ${PYTHONIKA}tm.o ${LIBS} -o ${PYTHONIKA}

${PYTHONIKA}tm.o: ${PYTHONIKA}.tm
    ${MPREP} ${PYTHONIKA}.tm -o ${PYTHONIKA}tm.c
	${CC} -c ${PYTHONIKA}tm.c ${INCLUDES}

${PYTHONIKA}.o: ${PYTHONIKA}.c
    ${CC} -c ${PYTHONIKA}.c ${INCLUDES}

clean :
    rm -f ${PYTHONIKA}tm.* ${PYTHONIKA}.o ${PYTHONIKA}

Now open the Pythonika.nb notebook and run the code.

I'll update this if I find any issues.

share|improve this answer
3  
I edited your post directly include the code rather than your google drive file, which is less permanent. – anderstood yesterday

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.