FEniCS / dolfinx

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

circular import #2371

Closed matteoicardi closed 1 year ago

matteoicardi commented 1 year ago

I have compiled on Mac M1, it all compiles but cannot import the module

ImportError                               Traceback (most recent call last)
Cell In [17], line 1
----> 1 import dolfinx

File ~/fenicsx/dolfinx/python/dolfinx/__init__.py:29
     23 # Reset dl open flags
     24 # sys.setdlopenflags(stored_dlopen_flags)
     25 # del sys
     27 import sys
---> 29 from dolfinx import common
     30 from dolfinx import cpp as _cpp
     31 from dolfinx import fem, geometry, graph, io, jit, la, log, mesh, nls, plot

File ~/fenicsx/dolfinx/python/dolfinx/common.py:10
      6 """General tools for timing and configuration"""
      8 import functools
---> 10 from dolfinx import cpp as _cpp
     11 from dolfinx.cpp.common import (IndexMap, git_commit_hash, has_adios2,  # noqa
     12                                 has_debug, has_kahip, has_parmetis)
     14 __all__ = ["IndexMap", "Timer", "timed"]

ImportError: cannot import name 'cpp' from partially initialized module 'dolfinx' (most likely due to a circular import) (/Users/pmzmi1/fenicsx/dolfinx/python/dolfinx/__init__.py)

am I doing something wrong or is something broken here?

jorgensd commented 1 year ago

I have compiled on Mac M1, it all compiles but cannot import the module

ImportError                               Traceback (most recent call last)
Cell In [17], line 1
----> 1 import dolfinx

File ~/fenicsx/dolfinx/python/dolfinx/__init__.py:29
     23 # Reset dl open flags
     24 # sys.setdlopenflags(stored_dlopen_flags)
     25 # del sys
     27 import sys
---> 29 from dolfinx import common
     30 from dolfinx import cpp as _cpp
     31 from dolfinx import fem, geometry, graph, io, jit, la, log, mesh, nls, plot

File ~/fenicsx/dolfinx/python/dolfinx/common.py:10
      6 """General tools for timing and configuration"""
      8 import functools
---> 10 from dolfinx import cpp as _cpp
     11 from dolfinx.cpp.common import (IndexMap, git_commit_hash, has_adios2,  # noqa
     12                                 has_debug, has_kahip, has_parmetis)
     14 __all__ = ["IndexMap", "Timer", "timed"]

ImportError: cannot import name 'cpp' from partially initialized module 'dolfinx' (most likely due to a circular import) (/Users/pmzmi1/fenicsx/dolfinx/python/dolfinx/__init__.py)

am I doing something wrong or is something broken here?

How did you install DOLFINx? This error message usually happens when the cpp interface has not been properly installed.

jhale commented 1 year ago

The following GitHub action might help you install on Mac if you are using Homebrew:

https://github.com/FEniCS/dolfinx/blob/main/.github/workflows/macos.yml

matteoicardi commented 1 year ago

thanks! I have recompiled everything and it works fine now