CNS-OIST / STEPS

Public release repository for STochastic Engine of Pathway Simulation (STEPS)
http://steps.sourceforge.net
Other
38 stars 10 forks source link

Errors in installing STEPS 4 on Ubuntu #32

Closed zhaolun7 closed 1 year ago

zhaolun7 commented 1 year ago

Hello, I am trying to install STEP 4, and I meet some errors. I try to fix the errror: FutureWarning: Cython directive 'language_level' not set, using 2 for now (Py2). This will change in a later release! so that I add a line in every .pyx file with command sed '2i# cython:language_level=3' -i *.pyx, and I meet this error:

image

It seems all files named '.pyx' are written with standard of py 2, so that it will meet some errors when compiling with cython -3 . So in this case I must install mpi4py on both python 2 and 3, and execute command `sed -i 's/language_level=3/language_level=2/' .pyx` I want to know if STEPS use both python 2 and 3 to compile? and in future will STEP's code migrate to 3?

jlallouette commented 1 year ago

Hello @zhaolun7, thank you for your report. You can likely fix these errors by using # cython:language_level=3str instead of # cython:language_level=3.

Regarding the original FutureWarning: Cython directive 'language_level' not set [...] message you got, it should be just a warning and should not prevent STEPS from running properly.

Note that you do not need to install packages like mpi4py for both python 2 and 3, the current release of STEPS requires Python 3.6 or higher. The language_level directive is specific to Cython and controls how Cython interprets the code in the .pyx files. Even if language_level is left to 2, the resulting .so file can be used by Python 3 without issues.

That being said, we will probably add the # cython:language_level=3str to .pyx files in the next release to prevent the warning from being displayed.

More on Python 2/3 semantics in Cython and the language_level directive there: https://docs.cython.org/en/latest/src/userguide/faq.html?highlight=language_level#what-python-versions-does-cython-support

zhaolun7 commented 1 year ago

@jlallouette Thank you for your solution. I am not familiar with the grammar in cython. so adding the # cython:language_level=3str line will fix the problem, I will test it later. In addition, I do an experiment as follows. I uninstall the mpi4py module on python 2 via command pip2 uninstall mpi4py image then I run make command, get: image It does prevent STEPS from running properly. And I look at the code of one file, find that it seems use other module in it. image I think STEPS use modules from python 2 via cython. This might be historical reasons. And to verify my idea I reinstall mpi4py module on python 2 and add some error code to its mpi.pxd: image then I run make command again: image This comparative experiment proves that the code of STEP does mix different python versions. And to solve this I have to install mpi4py on both python 2 and 3, or add # cython:language_level=3str to every .pyx file.

zhaolun7 commented 1 year ago

I have another question, if I remove the build folder, I can't use STEP: image It may be some shared libraries located at temp build folder, that cause I can't migrate the compiled STEPS package to other linux machine(That linux server may not allowed to install too much packages.) I may need to copy the compiled build directory and keep both paths the same. Is there any way or variable to specify the installation location of the dependent library or use a relative path link?

jlallouette commented 1 year ago

Thank you for the additional reports @zhaolun7. Unfortunately, I could not reproduce the cython / mpi4py issue you mentioned, cython (version 0.29.32) always used mpi4py from python3, even when language_level was set to 2. Which version of cython are you using?

Regarding the sundials shared libraries, you can get them to load from another directory using export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/path/to/sundials/libraries/. You can also install them in a different directory using the -DCMAKE_INSTALL_PREFIX=/custom/install/prefix cmake argument.

zhaolun7 commented 1 year ago

I install a new vm and test again, it still happen: image this is my OS version: image

zhaolun7 commented 1 year ago

If I use apt uninstall cython, it will say: /usr/bin/cython not found

zhaolun7 commented 1 year ago

and I test # cython:language_level=3str it still failed. image

jlallouette commented 1 year ago

Hello @zhaolun7, I noticed that Linux Mint has a separate cython3 package (https://community.linuxmint.com/software/view/cython3) so it could be that the one you are using (cython) is trying to load mpi4py from python 2 by default.

zhaolun7 commented 1 year ago

I use Ubuntu 22.04 to test compiling. In this desktop version, python 2 is no longer the default python version, and the command python is not exist. it will cause errors like: image after using command ln -s /usr/bin/python3 /usr/bin/python to solve it, STEP could be compiled successfully. The problem of mixing Python versions is most likely due to differences in the package management of Linux distributions.