lesgourg / class_public

Public repository of the Cosmic Linear Anisotropy Solving System (master for the most recent version of the standard code; GW_CLASS to include Cosmic Gravitational Wave Background anisotropies; classnet branch for acceleration with neutral networks; ExoCLASS branch for exotic energy injection; class_matter branch for FFTlog)
234 stars 290 forks source link

Installation of the Python Wrapper on Windows? #373

Open davidesk opened 3 years ago

davidesk commented 3 years ago

Hi all, I'm encountering huge problems when trying to install the Python wrapper on my windows machine. I'm using Spyder, installed with Anaconda. When using the makecommand Anaconda prompt in theclass_public-2.9.4 folder I get the following error: process_begin: CreateProcess(NULL, pwd, ...) failed. Makefile:4: pipe: No error gcc -O4 -ffast-math -fopenmp -g -fPIC -o class build/growTable.o build/dei_rkck.o build/sparse.o build/evolver_rkck.o build/evolver_ndf15.o build/arrays.o build/parser.o build/quadrature.o build/hyperspherical.o build/common.o build/trigonometric_integrals.o build/input.o build/background.o build/thermodynamics.o build/perturbations.o build/primordial.o build/nonlinear.o build/transfer.o build/spectra.o build/lensing.o build/hyrectools.o build/helium.o build/hydrogen.o build/history.o build/output.o build/class.o -lm process_begin: CreateProcess(NULL, gcc -O4 -ffast-math -fopenmp -g -fPIC -o class build/growTable.o build/dei_rkck.o build/sparse.o build/evolver_rkck.o build/evolver_ndf15.o build/arrays.o build/parser.o build/quadrature.o build/hyperspherical.o build/common.o build/trigonometric_integrals.o build/input.o build/background.o build/thermodynamics.o build/perturbations.o build/primordial.o build/nonlinear.o build/transfer.o build/spectra.o build/lensing.o build/hyrectools.o build/helium.o build/hydrogen.o build/history.o build/output.o build/class.o -lm, ...) failed. make (e=2): Impossible to find the specified file. make: *** [Makefile:141: class] Error 2

Did anyone manage to install the wrapper on a Windows machine? Thank you very much.

pstoecker commented 3 years ago

This appears to be actually an issue that is not related to the python wrapper but to compiling class itself.

You should take into account that the makefile assumes that you are on a unix-based system and to make it work with Windows you must adjust the file accordingly. For examples, it seems that you want to use gcc as compiler rather than the visual Studio compiler for Windows such that this will not work when you haven't gcc installed on your machine.

davidesk commented 3 years ago

I have installed gcc, so I guess that the issue must refer to something else... Do you have any idea if there are other options I need to change in the Makefile?

pstoecker commented 3 years ago

I wonder if it fails right away or whether it is something which only happens in context of the class target of the makefile (which is in line 141, the line where it fails for you).

Could you try to run make libclass.a and when this works try 'make classy'. You will then have the python wrapper but not the separate class executable, which you would not really need in your case.

You could also run make classy right away as it implies the libclass.a make target. I just suggest the split in case the first step already fails.

davidesk commented 3 years ago

The make libclass.a command generates the following message:

process_begin: CreateProcess(NULL, pwd, ...) failed.
Makefile:4: pipe: No error
make: 'libclass.a' is up to date.

while with make classy I get:

process_begin: CreateProcess(NULL, pwd, ...) failed.
Makefile:4: pipe: No error
cp python/setup.py python/autosetup.py
process_begin: CreateProcess(NULL, cp python/setup.py python/autosetup.py, ...) failed.
make (e=2): Impossible to find specified file.
make: *** [Makefile:176: classy] Error 2
pstoecker commented 3 years ago

OK. I guess I see what is happening.

During the make classy step there are a few commands executed that seem to assume a unix-based system and might not work on Windows.

For example in line 176

cp python/setup.py python/autosetup.py

may cause trouble.

I am no expert in Windows, but there might be no program called cp in windows to copy python/setup.py to python/autosetup.py. You may need to adjust this command there.

Also one should be aware that on unix-based systems a (forward) slash is used for file paths whereas windows uses backslashes as far as I know. But this should have caused troubles before in the Makefile.

Another problematic bit could be export CC=$(CC) in line 180

cd python; export CC=$(CC); $(PYTHON) autosetup.py install || $(PYTHON) autosetup.py install --user

as this will set the environment variable CC to the compiler in use (gcc in this case). I am not sure if this works on Windows

davidesk commented 3 years ago

Thanks, I'll try to find a way to translate these commands then. I have tried to repeat the whole process in the Ubuntu shell in the Windows terminal and the wrapper is installed; however, when executing the program using python program.py I get segmentation fault (core dumped) which is odd, since the program works just fine on my linux machine :(