I have 2 versions of python installed, but cmake is using older version. How do I force cmake to use the newer version?
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.
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.
You may try either of these depending on what you need:
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.
CMake < 3.12
Docs:
find_package(PythonInterp 2.7 REQUIRED) find_package(PythonLibs 2.7 REQUIRED)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With