Cantera / cantera

Chemical kinetics, thermodynamics, and transport tool suite
https://cantera.org
Other
581 stars 342 forks source link

Cantera import error in python #1636

Closed klrqst closed 8 months ago

klrqst commented 8 months ago

System information Cantera version 3.0.0 Ubuntu-20.04 Python version 3.8.10 GNU fortran version 9.4.0

Expected Behavior Compiling the Cantera python package

Compilation and installation steps

git clone --recursive https://github.com/Cantera/cantera.git 
cd cantera/ 
scons build python_package='y'

Error reporting

/usr/bin/ld: /usr/local/lib/libfmt.a(format.cc.o): relocation R_X86_64_PC32 against symbol stderr@@GLIBC_2.2.5' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: bad value
collect2: error: ld returned 1 exit status
scons: *** [build/lib/libcantera_shared.so.3.1.0] Error 1
scons: building terminated because of errors.

Solution sudo apt install libfmt-dev Compilation successful.

pip install ruamel.yaml
scons install

Installed successfully.

Loading environment

export PYTHONPATH=/mnt/d/code/code_git/cantera/cantera3.0/lib/canterabuild/lib/python3.8/site-packages:$PYTHONPATH
export LD_LIBRARY_PATH=/mnt/d/code/code_git/cantera/cantera3.0/lib/canterabuild/lib:$LD_LIBRARY_PATH
export PATH=/mnt/d/code/code_git/cantera/cantera3.0/lib/canterabuild/bin:$PATH

Run a case in python python3 burner_flame.py

Error

import cantera as ct
File "/mnt/d/code/code_git/cantera/cantera3.0/lib/canterabuild/lib/python3.8/site-packages/cantera/init.py", line 4, in
from ._cantera import *
ImportError: /mnt/d/code/code_git/cantera/cantera3.0/lib/canterabuild/lib/libcantera_shared.so.3: undefined symbol: _ZN3fmt2v812format_errorD1Ev

May I ask how to resolve this error? Thank you very much!!

speth commented 8 months ago

The initial error message mentions the file /usr/local/lib/libfmt.a, suggesting a "local" installation of libfmt. However, you then installed a copy of libfmt at the system level, and I suspect the two are getting mixed together (and are different versions of libfmt). I would suggest removing your local installation from /usr/local -- both the header files in /usr/local/include as well as the library files in /usr/local/lib.

ischoegl commented 8 months ago

I am closing this question - in case there are any additional difficulties, please post on the Cantera User's group - https://groups.google.com/group/cantera-users