Packages and dependencies for UMESH creation

Dear FLUKA team, Volodymyr,
With great interest, I set out to convert a step file to a UMESH geometry. In my Ubuntu 24 LTS machine, I installed gmsh ( I tried from source and sudo apt install python3-gmsh and I see some confusion there).

gmsh --version
4.13.1
dpkg --list | grep gmsh
ii  gmsh                                             4.12.1+ds1-1.1build2                     amd64        Three-dimensional finite element mesh generator
ii  gmsh-doc                                         4.12.1+ds1-1.1build2                     all          Three-dimensional finite element mesh generator documentation
ii  libgmsh4.12t64:amd64                             4.12.1+ds1-1.1build2                     amd64        Three-dimensional finite element mesh generator shared library
ii  python3-gmsh                                     4.12.1+ds1-1.1build2                     all          Three-dimensional finite element mesh generator Python 3 wrapper

but I probably did not install everything that was needed for this.

python3 ~/geom_mesh_utils/FLUKA_mesh_fix.py Ring_QuaDipole_full.step 
meshlib.mrmeshpy is not installed!
 	       Please check Meshlib link in the README for installation instructions.
Traceback (most recent call last):
  File "/home/sunil/geom_mesh_utils/FLUKA_mesh_fix.py", line 74, in <module>
    def heal( mesh : mm.Mesh, voxelSize : float,dError : float = 0.25, decimate : bool = True)->mm.Mesh:
                     ^^
NameError: name 'mm' is not defined

meshlib says I can install it by pip install meshlib But I get (with and without sudo)

pip install meshlib
error: externally-managed-environment

× This environment is externally managed
╰─> To install Python packages system-wide, try apt install
    python3-xyz, where xyz is the package you are trying to
    install.

When I do so, I get;

sudo apt install python3-meshlib
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
E: Unable to locate package python3-meshlib

Clearly, I am not doing this correctly, and I was hoping to get a set of detailed instructions including for the necessary packages and dependencies to make this work.
Cheers,
Sunil

Dear Sunil,

Starting with Ubuntu 24.04, it is not allowed to install pip packages for the system-wide Python installation with pip to prevent a clash between packages.

To solve the problem, you need to create a virtual Python environment with venv. For instructions, see: Install packages in a virtual environment using pip and venv - Python Packaging User Guide

By default, this environment won’t be able to access the system’s Python packages. This is useful if you are a Python programmer, and your projects require different package versions. However, if you only want to add a pip package that is not available as a system package it is cumbersome to reinstall all packages from pip.

Luckily, if you use the --system-site-packages during the creation of the virtual environment, you will be able to access the system packages.

After activating the virtual environment, you can simply install the missing package with pip.

Cheers,
David

2 Likes

Dear @sunil,

I fully agree with @horvathd, it’s better to install these packages in a separate Python environment as recommended in the guide: Generation via Gmsh

In this way, you will prevent any modifications of dependencies by installing any future packages

Cheers,
Volodymyr

Dear David and Volodymyr,
Thank you for the solution. I was able to install the virtual environment, the necessary packages and convert the snowman.step to inp and flair files.
Below are the steps that helped me on my Ubuntu 24 machine.

sudo apt install python3.12-venv
python3 -m venv --system-site-packages .venv
source .venv/bin/activate
which python
/home/sunil/.venv/bin/python
pip install --upgrade gmsh
pip install meshlib

Then, using the snowman.step from the wherever/geom_mesh_utils/examples/CAD/ directory available when geom_mesh_utils is unpacked,
python3 ~/geom_mesh_utils/FLUKA_mesh_fix.py snowman.step
produces snowman.abaq and a few other files.

Open flair :arrow_right: input :arrow_right:new :arrow_right: umesh, and load snowman.abaq in the umesh card and follow the instructions here.

Have fun!

Cheers, Sunil

1 Like

Dear @sunil,

Great that you have managed to mesh and load my snowman :grinning:

Have fun!

Cheers, Volodymyr

P.S. Snowman’s eyes should be there too