Since then, I have used the same command multiple times and everything works fine. However, a week ago I tried the same thing and trying to import mshr using from mshr import * I get the following error:
File "/home/hwan/Documents/Github_Codes/Thermal_Fin_Heat_Simulator/Generate_and_Save_Thermal_Fin_Data.py", line 18, in <module>
from Thermal_Fin_Heat_Simulator.Utilities.forward_solve import Fin
File "../Thermal_Fin_Heat_Simulator/Utilities/forward_solve.py", line 3, in <module>
from mshr import *
File "/home/hwan/anaconda3/envs/fenics_env_2019/lib/python3.7/site-packages/mshr/__init__.py", line 24, in <module>
from .cpp import Circle
ImportError: generic_type: type "CSGGeometry" referenced unknown base type "dolfin::Variable"
Has there been a change to the 2019.1.0 version? Anyone else encounter this issue? I reverted to the 2018 version and everything is fine. Also, what version does the command conda install -c conda-forge fenics, is it 2019.1.0 for python 3.8?
I had a similar problem and after a lot of trial-and-error, the following fix worked for me. From the file __init__.py in the subfolder lib/python3.7/site-packages/mshr of the environment in which the problem occurred, I removed the following lines:
from .cpp import Circle
from .cpp import Ellipse
from .cpp import Rectangle
from .cpp import Polygon
from .cpp import Sphere
from .cpp import Box
from .cpp import Cylinder
from .cpp import Cone
from .cpp import Tetrahedron
from .cpp import Surface3D
from .cpp import Ellipsoid
from .cpp import Rectangle
from .cpp import Extrude2D
from .cpp import CSGCGALDomain3D
from .cpp import CSGIntersection
from .cpp import CSGDifference
from .cpp import CSGUnion
from .cpp import CSGScaling
from .cpp import CSGTranslation
from .cpp import CSGRotation
from .cpp import CSGGeometries
from .cpp import UnitSphereMesh
from .cpp import CSGCGALMeshGenerator3D
from .cpp import TetgenMeshGenerator3D
from .cpp import CSGCGALDomain2D
from .cpp import CSGCGALMeshGenerator2D
from .cpp import generate_mesh
thereby leaving only one active statement in the whole file, namely:
I did the same as Hwan but to avoid confusing versions I created a new environment which I called fenics2018 with the 2018 version of fenics and mshr
since I work with jupyter notebook I did the following
later I added matplotlib also
conda install -n fenics2018 matplotlib
then everything works.
I wonder why with mshr 2019.1.0 and fenics 2019.1.0
I get the following error
ImportError Traceback (most recent call last)
in
----> 1 from mshr import *
/anaconda3/envs/fenicsproject/lib/python3.7/site-packages/mshr/init.py in
22 import dolfin
23
ā> 24 from .cpp import Circle
25 from .cpp import Ellipse
26 from .cpp import Rectangle
ImportError: dlopen(/anaconda3/envs/fenicsproject/lib/python3.7/site-packages/mshr/cpp.cpython-37m-darwin.so, 2): Library not loaded: @rpath/libslepc.3.12.dylib
Referenced from: /anaconda3/envs/fenicsproject/lib/libmshr.2019.1.dylib
Reason: image not found
Thank you for your suggestion but slepc is installed I just checked with conda list
slepc 3.11.2 h1ce4c84_1 conda-forge
slepc4py 3.11.0 py37hc459697_0 conda-forge
By noticing that the error message could not load libslepc.3.12 I I installed slepc 3.12and everything works now.
So the cure is simply to conda install -n fenicsproject -c conda-forge slepc=3.12
replacing fenicsproject by your fenics environement name
As far as I can tell, this error happens when the mshr library is out-of-sync with the dolfin library. This might happen, for instance, if the dolfin package is updated or rebuilt, but the mshr package was not rebuilt against the new dolfin.
Looks like @azeradās package versions are now self-consistent with each other.
I wanted to stay with the 2019 version of fenics, so I tried several builds of mshr 2019.1.0 available on conda-forge. The second newest build worked for me. I created a new Conda environment with
Howdy Martin @MartinLenz !
I stumbled upon the fact that an install of FEniCS doesnāt necessarily mean that you get everything needed to run tutorial code (specifically matplotlib and mshr), I saw your point about available builds:
I was wondering, for an existing environment called āfenicsprojectā, if you just ran conda install -n fenicsproject -c conda-forge mshr=2019.1.0
would if default to the last build listed?
my command output (using your search) ends like this:
I am using Ubuntu 20.04, so I see the same build that @BenjaminRueth used, and I am using FEniCS 2019.1.0, so I know from this thread that I need mshr 2019.1.0 to match, but I donāt know where to go to find out the difference between these builds.
Any thoughts on which build I should use are most welcome!
Iām an engineer, so I like using Spyder as my IDE to debug and quickly run the code to see if the syntax is tracking (just going through tutorial codes you can find all sorts of buggy behavior and outdated syntax), without having to use a text editor and then execute the file in the terminal.
Even so, it appears that the PPA would have to separately install pieces (like mshr and matplotlib).
So, itās back to ādo we have to specify the build?ā and if so, āhow do we find out the difference between builds?ā
Iāve been looking at the documentation here, but Iām not finding answers about whatās different