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

Error when importing CCL - ccllib circular import (developer instalation) #1174

Open
luigilcsilva opened this issue Apr 11, 2024 · 1 comment

Comments

@luigilcsilva
Copy link

Hi, everyone!

I recently updated CCL (I am using the developer instalation), but now I am getting an error when I try to import the library. I'll leave the print below. If anyone can help me, I would be very grateful!

error-importing-CCL

@luigilcsilva
Copy link
Author

I made a few attempts here and ultimately the issue was fixed.

Activate virtual environment

source /home/luigi/.conda/envs/cosmology/bin/activate

Or, simply

conda activate cosmology

Dependency install

pip install numpy
pip install cmake

Tried to run "python setup.py build" in CCL directory, but I got an error message, so I followed the steps below.

Changed the /home/luigi/cosmology/CCL/cmake/Modules/FindNumPy.cmake file content to (probably it is a good idea to make a backup of the original file):

echo 'find_package(PythonInterp REQUIRED)
execute_process(
COMMAND ${PYTHON_EXECUTABLE} -c "import numpy; print(numpy.path[0])"
OUTPUT_VARIABLE NumPy_PATH
OUTPUT_STRIP_TRAILING_WHITESPACE
)

set(NumPy_INCLUDE_DIR "${NumPy_PATH}/core/include")
set(NumPy_FOUND TRUE)' > ~/cosmology/CCL/cmake/Modules/FindNumPy.cmake

Defined the "build" directory permissions:

sudo chmod -R 777 ~/cosmology/CCL/build

Edited the file CMakeLists.txt and added the following lines (/home/luigi/cosmology/CCL/CmakeLists.txt) (probably it is a good idea to make a backup of the original file).

echo 'cmake_minimum_required(VERSION 3.5)
cmake_policy(SET CMP0078 OLD)
cmake_policy(SET CMP0086 OLD)
cmake_policy(SET CMP0148 OLD)' | cat - ~/cosmology/CCL/CMakeLists.txt > temp && mv temp ~/cosmology/CCL/CMakeLists.txt

Remove all the files from the build directory:

rm -rf ~/cosmology/CCL/build/*

Get the path of 'arrayobject.h' file:

python -c "import numpy; print(numpy.get_include())"

Edited again the CMakeLists.txt file, including the path in it:

include_directories(/home/luigi/.conda/envs/cosmology/lib/python3.12/site-packages/numpy/core/include)

Configured again:

cd ~/cosmology/CCL/build
rm -rf *
cmake -DPYTHON_EXECUTABLE=/home/luigi/.conda/envs/cosmology/bin/python ..
cd ~/cosmology/CCL
python setup.py build

The above steps were actually performed for a sequence of problems that appeared. You may not need all of them to solve your problem.

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

1 participant