[CMake] FindPython3 Python_FIND_VIRTUALENV seems to be ignored

sebastian.mueller3 at zf.com sebastian.mueller3 at zf.com
Thu Aug 1 05:18:16 EDT 2019


Hi all,

I've been trying to convince Cmake 15.1 to use the python installation in my virtual anaconda environment rather than the anaconda base installation.
I'm using this to find python:

set(Python3_FIND_VIRTUALENV "FIRST")
find_package(Python3 3.6.8 EXACT COMPONENTS Development NumPy)

First, I'm using Anaconda Prompt to execute the commands. I `activate testenv`, to activate my environment.
When I then run `cmake .. -G "Visual Studio 14 2015 Win64"`, I get this output:

-- Selecting Windows SDK version  to target Windows 10.0.16299.
-- The C compiler identification is MSVC 19.0.24215.1
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/x86_amd64/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/x86_amd64/cl.exe - works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Found Git: C:/app/tools/Git/cmd/git.exe (found version "2.17.1.windows.2")
-- Could NOT find Python3: Found unsuitable version "3.6.4", but required is exact version "3.6.8" (found C:/app/anaconda3/libs/python36.lib)
-- Configuring done
-- Generating done
-- Build files have been written to: D:/src/project/vsbuild

I would expect cmake rather to find the python in C:/app/anaconda3/envs/testenv/... since this is the active environment and according to the
HINT I set it to be favored over other python installations (as documented in https://cmake.org/cmake/help/v3.15/module/FindPython3.html).

Additional info:
$ which python
C:/app/anaconda3/envs/testenv/python.exe
$ python -version
Python 3.6.8 :: Anaconda, Inc.

I'm working on Windows 10. Any ideas what is going wrong?

Kind regards/Viele Grüße
Sebastian Müller

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cmake.org/pipermail/cmake/attachments/20190801/79bb59cc/attachment.html>


More information about the CMake mailing list