ImportError: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.29' not found

Here is the structure of my project.simulation.py is imported by hunter.py

|-- envs
|   |-- active_flow_control.py
|   |-- hunter.py
|   |-- passive_flow_control.py
|   `-- test.py
|-- fluid_mechanics
|   |-- __pycache__
|   |   |-- area.cpython-310.pyc
|   |   `-- simulation.cpython-310.pyc
|   |-- area.py
|   `-- simulation.py
|-- main.py
|-- test
|   |-- drl_test.py
|   `-- fenicsx_test.py
`-- utils
    `-- encoder.py

I met this ImportError when I run hunter.py. And it’s strange that It worked well when I run simulation.py separately.Here are the full error information:

Traceback (most recent call last):
  File "/home/wulong/jzz/single_drl_for_passive_control/envs/hunter.py", line 4, in <module>
    from fluid_mechanics.simulation import *
  File "/home/wulong/jzz/single_drl_for_passive_control/fluid_mechanics/simulation.py", line 9, in <module>
    from dolfinx.cpp.mesh import to_type, cell_entity_type
  File "/home/wulong/anaconda3/envs/drl/lib/python3.10/site-packages/dolfinx/__init__.py", line 29, in <module>
    from dolfinx import common
  File "/home/wulong/anaconda3/envs/drl/lib/python3.10/site-packages/dolfinx/common.py", line 11, in <module>
    from dolfinx import cpp as _cpp
ImportError: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.29' not found (required by /home/wulong/anaconda3/envs/drl/lib/python3.10/site-packages/dolfinx/cpp.cpython-310-x86_64-linux-gnu.so)

Update:I found this error happened if gymnasium and dolfinx are imported concurrently.Maybe some libraries are incompatible with dolfinx.

I have not heard about the gymnasium package. Is it on conda-forge? Did you install it with conda-forge?

Yes,both gymnasium and fenicsx are installed by conda-forge.The version of gymnasium is 0.27.1 and fenicsx is 0.6.0

I cannot reproduce this with conda on my system:

name: gymtest
channels:
  - conda-forge
dependencies:
  - fenics-dolfinx
  - gymnasium

calling

conda env create -f environment.yml 

then

 conda activate gymtest
 python3 -c "import dolfinx; print(dolfinx.__version__);import gymnasium; print(gymnasium.__version__)"

returning

0.6.0
0.27.1

Thanks for your test.I found this error may be caused by Anaconda.
I have solved this error follow this