CLion doesn't use the python interpreter


I have a valid python virtualenv (python 3.6.6), called in my case "boost", selected in CLion / Preferences / Build, Execution, Deployment / Python Interpreter

However, when CLion calls cmake, it doesn't do so within that interpreter, meaning that anything related to python in cmake picks up the system python version instead of the version installed in the virtualenv (3.6.6).

Is this intentional (and if so, what's the purpose of being able to select a python interpreter at all?). Is it possible to make CLion use the selected interpreter for its environment?

Thanks for any help you can offer!

Comment actions Permalink

OK here'a a workaround - run clion from a terminal with your virtualenv activated:

pyenv activate <my-env-name>

That way, any calls within cmake that use python, such as:

FIND_PACKAGE(PythonInterp 3)

Find the correct python interpreter.

Use cases:

- Using cmake to build a docs target, where sphinx is used to build documentation (which may require a non-system python version) (e.g. google's ceres-solver does this very nicely)

- Using cmake to build targets which use boost::python (or presumably cython)


Comment actions Permalink

We've also found this to be an issue. Is it just a bug or intended behaviour?

Comment actions Permalink

I will be really happy for a workaround...


Comment actions Permalink

It seems to be CMake-related question, not CLion-related one. I suppose you can set the path to the Python interpreter using Python_EXECUTABLE CMake variable (see


Please sign in to leave a comment.