FEniCS / dolfinx

Next generation FEniCS problem solving environment
https://fenicsproject.org
GNU Lesser General Public License v3.0
779 stars 181 forks source link

[BUG]: ImportError: initialization failed #2595

Closed Novice-me closed 1 year ago

Novice-me commented 1 year ago

How to reproduce the bug

i ran the poisson equation demo of the dolfinx 0.7.0.0, errors occured in the import modules stage of implementation

Minimal Example (Python)

from dolfinx import fem

Output (Python)

Traceback (most recent call last):
  File "/home/cyc/anaconda3/lib/python3.9/site-packages/basix/__init__.py", line 7, in <module>
    from ._basixcpp import __version__
ImportError: /home/cyc/anaconda3/lib/python3.9/site-packages/basix/_basixcpp.cpython-39-x86_64-linux-gnu.so: undefined symbol: _ZN5basix7versionB5cxx11Ev

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/cyc/anaconda3/lib/python3.9/site-packages/dolfinx/__init__.py", line 29, in <module>
    from dolfinx import common
  File "/home/cyc/anaconda3/lib/python3.9/site-packages/dolfinx/common.py", line 11, in <module>
    from dolfinx import cpp as _cpp
ImportError: initialization failed

Version

0.6.0

DOLFINx git commit

(base) cyc@cyc-Z10PA-D8-Series:~$ python3 -c "import dolfinx; print(dolfinx.common.git_commit_hash)"
Traceback (most recent call last):
  File "/home/cyc/anaconda3/lib/python3.9/site-packages/basix/__init__.py", line 7, in <module>
    from ._basixcpp import __version__
ImportError: /home/cyc/anaconda3/lib/python3.9/site-packages/basix/_basixcpp.cpython-39-x86_64-linux-gnu.so: undefined symbol: _ZN5basix7versionB5cxx11Ev

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/cyc/anaconda3/lib/python3.9/site-packages/dolfinx/__init__.py", line 29, in <module>
    from dolfinx import common
  File "/home/cyc/anaconda3/lib/python3.9/site-packages/dolfinx/common.py", line 11, in <module>
    from dolfinx import cpp as _cpp
ImportError: initialization failed

Installation

    • Ubuntu version : Linux version 5.19.0-35-generic (buildd@lcy02-amd64-020) (x86_64-linux-gnu-gcc (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0, GNU ld (GNU Binutils for Ubuntu) 2.38) #36~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Fri Feb 17 15:17:25 UTC 2 and
    • DOLFINx version : dolfinx version = 0.6.0
    • mpich version :
      MPICH Version:      4.1.1
      MPICH Release date: Mon Mar  6 14:14:15 CST 2023
      MPICH ABI:          15:0:3
      MPICH Device:       ch3:nemesis
      MPICH configure:    --prefix=/usr/local/bin/mpich --enable-shared --with-device=ch3:nemesis
      MPICH CC:           gcc    -O2
      MPICH CXX:          g++   -O2
      MPICH F77:          gfortran   -O2
      MPICH FC:           gfortran   -O2
    • hdf5 features :
      Features:
      ---------
                       Parallel HDF5: yes
      Parallel Filtered Dataset Writes: yes
                  Large Parallel I/O: yes
                  High-level library: yes
      Dimension scales w/ new references: no
                    Build HDF5 Tests: yes
                    Build HDF5 Tools: yes
                     Build GIF Tools: no
                        Threadsafety: no
                 Default API mapping: v114
      With deprecated public symbols: yes
              I/O filters (external): deflate(zlib)
                       Map (H5M) API: no
                          Direct VFD: no
                          Mirror VFD: no
                       Subfiling VFD: no
                  (Read-Only) S3 VFD: no
                (Read-Only) HDFS VFD: no
      Packages w/ extra debug output: none
                         API tracing: no
                Using memory checker: no
              Function stack tracing: no
                    Use file locking: best-effort
           Strict file format checks: no
        Optimization instrumentation: no
    • C++ core built from source with optional packageSLEPC enabled (P.S. : petsc and slepc were built with arg --with-petsc4py=1 and --with-slepc4py=1 for petsc4py and slepc4py modules)
      • python version built with pip install . with using petsc4py.pth and slepc4py.pth mentioned in PETSc for Python Docs to specify the path of petsc4py and slepc4py modules

Additional information

No response

Novice-me commented 1 year ago

When i checked the error log again, I thought the problem might be caused by an inappropriate version of Basix. Following the instructions of Basix Advanced Installation , i built the c++ version then use pip install . to install Basix, which solves this BUG.