CMake choosing wrong Python interpreter

Asked by Andy R Terrel

CMake wants to use python2.7 on my system, but I want it to use python2.6 which has all the correct libraries set up. Anyone know how to set the correct interpreter?

Question information

Language:
English Edit question
Status:
Solved
For:
DOLFIN Edit question
Assignee:
No assignee Edit question
Solved by:
Johannes Ring
Solved:
Last query:
Last reply:
Revision history for this message
Johannes Ring (johannr) said :
#1

Try to add -DPYTHON_EXECUTABLE:FILEPATH=/path/to/python2.6 when configuring DOLFIN with CMake.

Revision history for this message
Andy R Terrel (andy-terrel) said :
#2

Johannes, thanks for the tip. Unfortunately, CMake still seems to pick up the python version as 2.7 which is causing trouble with the swig generators.

Revision history for this message
Johan Hake (johan-hake) said :
#3

On Monday December 13 2010 08:34:42 Andy R Terrel wrote:
> Question #137667 on DOLFIN changed:
> https://answers.launchpad.net/dolfin/+question/137667
>
> Status: Answered => Open
>
> Andy R Terrel is still having a problem:
> Johannes, thanks for the tip. Unfortunately, CMake still seems to pick
> up the python version as 2.7 which is causing trouble with the swig
> generators.

By looking at the FindPython.cmake on Maverick one should be able to set the
Python version by the CMakeVariable:

  CMAKE_USE_PYTHON_VERSION

Not sure this helps...

Johan

Revision history for this message
Johannes Ring (johannr) said :
#4

I think you need to remove the CMakeCache.txt file in the build directory. Did you try that?

Revision history for this message
Johan Hake (johan-hake) said :
#5

> Johannes Ring proposed the following answer:
> Try to add -DPYTHON_EXECUTABLE:FILEPATH=/path/to/python2.6 when
> configuring DOLFIN with CMake.

Johannes!

Is the

  PYTHON_EXECUTABLE

variable used when CMake configure the Python Library or is it only used when,
well, the Python executable is looked for?

It seems like Andy is having trouble finding the correct library.

Johan

Revision history for this message
Best Johannes Ring (johannr) said :
#6

@Johan: I'm not sure. FindPythonLibs.cmake doesn't use PYTHON_EXECUTABLE so you are probably right.

@Andy: Try to configure DOLFIN with -DPYTHON_INCLUDE_DIRS:PATH=/usr/include/python2.6 and -DPYTHON_LIBRARIES:FILEPATH:/usr/lib/libpython2.6.so (substitute /usr/include/2.6 and /usr/lib/libpython2.6.so as necessary).

Revision history for this message
Andy R Terrel (andy-terrel) said :
#7

@Johan: I had both problems =D It would use python2.7 as the executable and then crash when it couldn't import ufc. With the exectutable set to python2.6 it would generate incompatible swig wrappers (it was still choosing python2.7 wrappers).

@Johannes: So I've been playing with a lot of different configs on my system, each time removing the build directory. I'm running on top of MacPorts and updated recently so this could be a source of my problems.

Thanks for the pointers to the python variables. Once I set these in ufc as well everything built without error.

Revision history for this message
Andy R Terrel (andy-terrel) said :
#8

Thanks Johannes Ring, that solved my question.

Revision history for this message
Johan Hake (johan-hake) said :
#9

On Monday December 13 2010 11:13:48 Andy R Terrel wrote:
> Question #137667 on DOLFIN changed:
> https://answers.launchpad.net/dolfin/+question/137667
>
> Status: Answered => Solved

Andy: You are brave ;)

Great that it finally worked out for you!

Johan