Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to tell CMake to use Anaconda environment? #126

Open
jarmitage opened this issue Mar 28, 2023 · 4 comments
Open

How to tell CMake to use Anaconda environment? #126

jarmitage opened this issue Mar 28, 2023 · 4 comments

Comments

@jarmitage
Copy link

jarmitage commented Mar 28, 2023

When I add this to the CMake file:

execute_process (
    COMMAND bash -c "which python"
    OUTPUT_VARIABLE outVar
)

message(STATUS "path: ${outVar}")

I get the correct Python path for my current conda environment.

But, I am getting ModuleNotFoundError: No module named 'taichi' errors when running python ./ci/run_tests.py -l $TAICHI_C_API_INSTALL_DIR.

@PENGUINLIONG
Copy link
Member

Someone met the same problem before and it seems old CMake's FindPython.cmake doesn't look for Python in conda environments. Please upgrade your CMake to 3.17 or higher.

@jarmitage
Copy link
Author

That's interesting, I am using CMake 3.26.1, but it sounds like it could be a similar issue.

I couldn't find any info about how to possibly intervene with FindPython that might help here though https://cmake.org/cmake/help/latest/module/FindPython3.html

Maybe the 'someone' you mentioned might know? Or do you remember anything else about their issue/solution?

@jarmitage
Copy link
Author

jarmitage commented Mar 28, 2023

Ok, changing this to 3.26 fixed it! Is that what you meant?

cmake_minimum_required(VERSION 3.13)

@jarmitage
Copy link
Author

jarmitage commented Mar 29, 2023

Ok, so to run the CI script on macOS using conda and Vulkan only, I had to:

set(CMAKE_PREFIX_PATH "/Users/xxx/.miniconda3/envs/my-env/")
find_package (Python ${MY_PYTHON_VERSION} EXACT REQUIRED)
  • Add set(CMAKE_PREFIX_PATH "/Users/xxx/.miniconda3/envs/my-env/") to the root CMakeFile as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants