Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I have 2 versions of python installed, but cmake is using older version. How do I force cmake to use the newer version?

I have 2 versions of python installed, but cmake is using older version. How do I force cmake to use the newer version?

like image 518
Sanjeev Avatar asked Mar 08 '13 10:03

Sanjeev


People also ask

What happens if I have 2 versions of Python?

There's nothing wrong with having two versions of python installed, and it's actually quite common to do so. Usually, one would install them with different names ( python vs python3 , for example) to avoid confusion though.

Can I have two versions of Python installed?

If you wish to use multiple versions of Python on a single machine, then pyenv is a commonly used tool to install and switch between versions. This is not to be confused with the previously mentioned depreciated pyvenv script. It does not come bundled with Python and must be installed separately.


1 Answers

You may try either of these depending on what you need:

For CMake >= 3.12

According to the changelog:

New "FindPython3" and "FindPython2" modules, as well as a new
"FindPython" module, have been added to provide a new way to locate
python environments.

find_package(Python COMPONENTS Interpreter Development) 

Docs:

This module looks preferably for version 3 of Python. If not found, version 2 is searched. To manage concurrent versions 3 and 2 of Python, use FindPython3 and FindPython2 modules rather than this one.

For CMake < 3.12

Docs:

find_package(PythonInterp 2.7 REQUIRED) find_package(PythonLibs 2.7 REQUIRED) 
like image 159
jadelord Avatar answered Sep 22 '22 02:09

jadelord