Error building ROS snapcraft when importing python libraries (numpy, matplotlib, etc)

Hi everyone.

Currently I’m working on building a ROS application on a snap package. Previously, I had an installation rule problem with C++ executables (here).

Now, I have a model_server.launch file that launches two nodes in python, like:

<launch>
  <node pkg="sick_app" name="server_classifier_A" type="model_classifier.py" output="screen" > 
  </node>

  <node pkg="sick_app" name="img_saver_A" type="image_generator.py" output="screen">
  </node>
</launch>

Now, I’m having a problem with the python part. After building the snap (snapcraft command) and install it, the following errors appears when I try to run the snap app. For the model_classifier.py:

Traceback (most recent call last):
  File "/snap/sick-snap-test/x1/usr/lib/python2.7/dist-packages/numpy/core/__init__.py", line 16, in <module>
    from . import multiarray
ImportError: cannot import name 'multiarray'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/snap/sick-snap-test/x1/opt/ros/melodic/lib/sick_app/model_classifier.py", line 2, in <module>
    import numpy as np
  File "/snap/sick-snap-test/x1/usr/lib/python2.7/dist-packages/numpy/__init__.py", line 142, in <module>
    from . import add_newdocs
  File "/snap/sick-snap-test/x1/usr/lib/python2.7/dist-packages/numpy/add_newdocs.py", line 13, in <module>
    from numpy.lib import add_newdoc
  File "/snap/sick-snap-test/x1/usr/lib/python2.7/dist-packages/numpy/lib/__init__.py", line 8, in <module>
    from .type_check import *
  File "/snap/sick-snap-test/x1/usr/lib/python2.7/dist-packages/numpy/lib/type_check.py", line 11, in <module>
    import numpy.core.numeric as _nx
  File "/snap/sick-snap-test/x1/usr/lib/python2.7/dist-packages/numpy/core/__init__.py", line 26, in <module>
    raise ImportError(msg)
ImportError: 
Importing the multiarray numpy extension module failed.  Most
likely you are trying to import a failed build of numpy.
If you're working with a numpy git repo, try `git clean -xdf` (removes all
files not under version control).  Otherwise reinstall numpy.

Original error was: cannot import name 'multiarray'

Traceback (most recent call last):
  File "/snap/sick-snap-test/x1/usr/lib/python2.7/dist-packages/numpy/core/__init__.py", line 16, in <module>
    from . import multiarray
ImportError: cannot import name 'multiarray'

And for the image_generator.py:

Traceback (most recent call last):
  File "/snap/sick-snap-test/x1/opt/ros/melodic/lib/sick_app/image_generator.py", line 2, in <module>
    import rospy
Traceback (most recent call last):
  File "/snap/sick-snap-test/x1/opt/ros/melodic/lib/python2.7/dist-packages/rospy/__init__.py", line 47, in <module>
  File "/snap/sick-snap-test/x1/opt/ros/melodic/lib/python2.7/dist-packages/std_msgs/msg/__init__.py", line 1, in <module>
    from ._Bool import *
  File "/snap/sick-snap-test/x1/opt/ros/melodic/lib/python2.7/dist-packages/std_msgs/msg/_Bool.py", line 6, in <module>
    import genpy
  File "/snap/sick-snap-test/x1/opt/ros/melodic/lib/python2.7/dist-packages/genpy/__init__.py", line 34, in <module>
    from . message import Message, SerializationError, DeserializationError, MessageException, struct_I
    import genpy
  File "/snap/sick-snap-test/x1/opt/ros/melodic/lib/python2.7/dist-packages/genpy/message.py", line 46, in <module>
    import genmsg
  File "/snap/sick-snap-test/x1/opt/ros/melodic/lib/python2.7/dist-packages/genmsg/__init__.py", line 33, in <module>
  File "/snap/sick-snap-test/x1/opt/ros/melodic/lib/python2.7/dist-packages/genpy/message.py", line 46, in <module>
    import genmsg
    from . base import MSG_DIR, SRV_DIR, EXT_MSG, EXT_SRV, SEP, log, plog, InvalidMsgSpec, log_verbose, MsgGenerationException
  File "/snap/sick-snap-test/x1/opt/ros/melodic/lib/python2.7/dist-packages/genmsg/base.py", line 52, in <module>
  File "/snap/sick-snap-test/x1/opt/ros/melodic/lib/python2.7/dist-packages/genmsg/__init__.py", line 33, in <module>
    import inspect, pprint
  File "/snap/sick-snap-test/x1/usr/lib/python3.6/inspect.py", line 41, in <module>
    import linecache
  File "/snap/sick-snap-test/x1/usr/lib/python3.6/linecache.py", line 11, in <module>
    import tokenize
  File "/snap/sick-snap-test/x1/usr/lib/python3.6/tokenize.py", line 33, in <module>
    import re
  File "/snap/sick-snap-test/x1/usr/lib/python3.6/re.py", line 142, in <module>
    class RegexFlag(enum.IntFlag):
AttributeError: module 'enum' has no attribute 'IntFlag'

I’m importing the following libraries in those scripts. For model_classifier.py:

#!/usr/bin/env python3
import numpy as np
import sys
import os
import csv
import getpass
from sick_app.srv import *
import math
import rospy
import time
import datetime
from time import strptime
from scipy.stats import zscore
from sick_app.msg import Img
import open3d as o3d
import matplotlib.pyplot as plt
import open3d as o3d

and for image_generator.py:

#!/usr/bin/env python3
import rospy
import os
from sick_app.msg import Img
import math
import time
import sys
import numpy as np
import matplotlib
matplotlib.use('Agg')
from matplotlib import pyplot as plt
import matplotlib.cm as cm
from PIL import Image, ImageFilter

As I found here, I added the python plugin to my snapcraft.yaml file:

parts:
  sick-app-workspace:
    # See 'snapcraft plugins'
    plugin: catkin
    source: .
    catkin-packages: [sick_app]
    stage-packages:
      - python3 
      - python3-pil
      - python3-tk
      - libblas-dev

  pythonpackages:  
    plugin: python
    python-version: python3
    python-packages: 
      - numpy
      - matplotlib
      - Pillow
      - scipy
      - open3d

Also (according to this) I added the exec_depend lines at the package.xml file:

<?xml version="1.0"?>
<package format="2">
  <name>sick_app</name>
  <version>0.0.0</version>
  <license>TODO</license>

  <buildtool_depend>catkin</buildtool_depend>
  <build_depend>roscpp</build_depend>
  <build_depend>rospy</build_depend>
  <build_depend>std_msgs</build_depend>
  <build_depend>tf</build_depend>
  <build_depend>eigen</build_depend>
  <build_depend>message_generation</build_depend>
  <build_depend>sick_scan</build_depend>
  <build_depend>roslaunch</build_depend>
  <build_export_depend>roscpp</build_export_depend>
  <build_export_depend>rospy</build_export_depend>
  <build_export_depend>std_msgs</build_export_depend>
  <build_export_depend>message_runtime</build_export_depend>
  <exec_depend>roscpp</exec_depend>
  <exec_depend>rospy</exec_depend>
  <exec_depend>std_msgs</exec_depend>
  <exec_depend>tf</exec_depend>
  <exec_depend>eigen</exec_depend>
  <exec_depend>message_runtime</exec_depend>
  <exec_depend>sick_scan</exec_depend>
  <exec_depend>python3-matplotlib</exec_depend>
  <exec_depend>python3-numpy</exec_depend>
  <exec_depend>python3-pil</exec_depend>
  <exec_depend>python3-scipy</exec_depend>
  
  <!-- The export tag contains other, unspecified, tags -->
  <export>
    <!-- Other tools can request additional information be placed here -->
  </export>
</package>

and my CMakeLists.txt looks like:

cmake_minimum_required(VERSION 3.0.2)
project(sick_app)

add_compile_options(-std=c++11)

find_package(catkin REQUIRED COMPONENTS
  roscpp
  rospy
  std_msgs
  tf
  genmsg
  sick_scan
  roslaunch
)
find_package(Eigen3 REQUIRED)
roslaunch_add_file_check(launch)
add_service_files(
  FILES
  model.srv
  )
  
add_message_files(
  FILES
  Img.msg
  )
  generate_messages(
  DEPENDENCIES
  std_msgs
  sick_app
  )
  
catkin_package(
  CATKIN_DEPENDS message_runtime std_msgs sick_scan
  )
    
include_directories(src ${EIGEN3_INCLUDE_DIRS})
include_directories(include ${catkin_INCLUDE_DIRS})

add_executable(node_filter
  src/node_filter.cpp
  src/filter.cpp
)
target_link_libraries(node_filter ${catkin_LIBRARIES} )
add_dependencies(node_filter sick_app_generate_messages_cpp)

add_executable(node_classifier
  src/node_classifier.cpp  
  src/constructor.cpp
  src/modelTool.cpp
  src/fileManager.cpp
)
target_link_libraries(node_classifier ${catkin_LIBRARIES} )
add_dependencies(node_classifier sick_app_generate_messages_cpp)


install(DIRECTORY launch
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
)

install(TARGETS node_filter
RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION})

install(TARGETS node_classifier
RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION})

## Install scripts
install(PROGRAMS scripts/model_classifier.py
  DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
)

install(PROGRAMS scripts/image_generator.py
  DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
)

I don’t know why snapcraft can’t find the python modules or why they are not packed with the snap file. I’ll be so thankful if someone could help me telling me what I need to fix this problem.

Thanks.

Update (16/02/2021)

I’ve carefully reviewed the package.xml and snapcraft.yaml declarations. At package.xml, I wrote all the <exec_depend> packages I use, all of them were checked using rosdep resolve <package-name>: (the open3d resolve was only different one, according to rosdep)

<?xml version="1.0"?>
<package format="2">
  <name>sick_app</name>
  <version>0.0.0</version>
  <license>TODO</license>

  <buildtool_depend>catkin</buildtool_depend>
  <build_depend>roscpp</build_depend>
  <build_depend>rospy</build_depend>
  <build_depend>std_msgs</build_depend>
  <build_depend>tf</build_depend>
  <build_depend>eigen</build_depend>
  <build_depend>message_generation</build_depend>
  <build_depend>sick_scan</build_depend>
  <build_depend>roslaunch</build_depend>
  <build_export_depend>roscpp</build_export_depend>
  <build_export_depend>rospy</build_export_depend>
  <build_export_depend>std_msgs</build_export_depend>
  <build_export_depend>message_runtime</build_export_depend>
  <exec_depend>roscpp</exec_depend>
  <exec_depend>rospy</exec_depend>
  <exec_depend>std_msgs</exec_depend>
  <exec_depend>tf</exec_depend>
  <exec_depend>eigen</exec_depend>
  <exec_depend>message_runtime</exec_depend>
  <exec_depend>sick_scan</exec_depend>

  <exec_depend>python3-numpy</exec_depend>
  <exec_depend>python3-scipy</exec_depend>
  <exec_depend>python3-matplotlib</exec_depend>
  <exec_depend>python3-pil</exec_depend>
  <exec_depend>python-open3d-pip</exec_depend>

  <!-- The export tag contains other, unspecified, tags -->
  <export>
    <!-- Other tools can request additional information be placed here -->
  </export>
</package>

At the snapcraft.yaml I have the following parts section:

parts:
  sick-app-workspace:
    plugin: catkin
    source: .
    catkin-packages: [sick_app]
    stage-packages:
      - python3-numpy
      - python3-dev
      - libblas3
      - liblapack3
      - libopenblas-dev
      - liblapack-dev  
      - python3-scipy
      - python3-matplotlib
      - python3-pil
  pip-things:
    plugin: python
    python-version: python3
    python-packages: 
    - open3d

First I tried to add the python-open3d-pip as a stage-package, but the snapcraft couldn’t find the package. That’s why I added the python plugin with the open3d python-packages. That shows me the following error:

Failed to stage: Parts 'pip-things' and 'sick-app-workspace' have the following files, but with different contents:
    bin/iptest
    bin/ipython
    bin/jsonschema
    bin/jupyter
    bin/jupyter-bundlerextension
    bin/jupyter-kernel
    bin/jupyter-kernelspec
    bin/jupyter-migrate
    bin/jupyter-nbconvert
    bin/jupyter-nbextension
    bin/jupyter-notebook
    bin/jupyter-run
    bin/jupyter-serverextension
    bin/jupyter-troubleshoot
    bin/jupyter-trust
    bin/pygmentize
    share/jupyter/nbextensions/open3d/extension.js
    share/jupyter/nbextensions/open3d/index.js
    share/jupyter/nbextensions/open3d/index.js.map

Snapcraft offers some capabilities to solve this by use of the following keywords:
    - `filesets`
    - `stage`
    - `snap`
    - `organize`

To learn more about these part keywords, run `snapcraft help plugins`.

I’m not sure how to handle the open3d library. I hope you could tell me how to solve this problem.

Thanks.

The last snapcraft.yaml you shared was using base: core18, which maps to ROS Melodic, which uses Python 2. However, you seem to be using Python 3 everywhere. I haven’t personally tried doing this, but I’d be pretty surprised if it works. You can see the issue by looking at your traceback:

File "/snap/sick-snap-test/x1/usr/lib/python2.7/dist-packages/numpy/core/__init__.py", line 26, in <module>
    raise ImportError(msg)

Take a close look: /snap/sick-snap-test/x1/usr/lib/python2.7. Your package.xml depends on Python 3 things, but it’s running as Python 2. I suggest sticking with Python 2, or updating to Noetic which supports Python 3.

If you properly depend upon something in your package.xml that maps to a deb with rosdep resolve, you do not need to also specify it in stage-packages. Snapcraft will take of that for you. This actually applies to pip dependencies as well (for Melodic anyway).

Hi @kyrofa As you suggested, we migrated to ROS Noetic, using the python3 modules. Everything was going perfect, until I got this error:

Add distro "noetic"
Skip distro "rolling" different from requested "noetic"
updated cache in /root/.ros/rosdep/sources.cache
+ rosdep install --default-yes --ignore-packages-from-source --from-paths /root/parts/sick-app-workspace/src
/usr/bin/python3: No module named pip
/usr/bin/python3: No module named pip
executing command [python3 -m pip install -U open3d-python]
/usr/bin/python3: No module named pip
ERROR: the following rosdeps failed to install
  pip: command [python3 -m pip install -U open3d-python] failed
Failed to build 'sick-app-workspace'.

Recommended resolution:
Check the build logs and ensure the part's configuration and sources are correct.

I checked the open3d library. It is already installed with pip (21.0.1 version). I’m currently using Python 3.8.5. Also at the package.xml file I’m declaring

<exec_depend>python-open3d-pip</exec_depend>

and the snapcraft.yaml looks like: (without stage-packages, as you suggested)

name: sick-snap-noetic # you probably want to 'snapcraft register <name>'
base: core20 # the base snap is the execution environment for this snap
version: '0.1' # just for humans, typically '1.2+git' or '1.3.2'
summary: Sick app snap test
description: |
  Demo snapcraft for ROS sick application, with Noetic distro.

grade: devel # must be 'stable' to release into candidate/stable channels
confinement: devmode # use 'strict' once you have the right plugs and slots

parts:
  sick-app-workspace:
    # See 'snapcraft plugins'
    plugin: catkin
    source: .
    catkin-packages: [sick_app]
apps:
  sick:
    command: roslaunch sick_app sick_sensor.launch
    plugs: [network, network-bind]
    extensions: [ros1-noetic]

  filter:
    command: roslaunch sick_app node_filter.launch
    plugs: [network, network-bind]
    extensions: [ros1-noetic]

  model:
    command: roslaunch sick_app model_server.launch
    plugs: [network, network-bind]
    extensions: [ros1-noetic]

According to the rosdep python yaml, python-open3d-pip is the unique reference for that library. When I run rosdep resolve python-open3d-pip, the output is open3d-python, but when I try it with rosdep resolve python3-open3d-pip there’s no rosdep rule. This is the unique library I’m struggling with.

Bah, it appears that rosdep doesn’t depend upon pip but expects it to be there :roll_eyes: . Try making python3-pip a build-package. That should unblock you short-term, but it’s something we can fix in snapcraft (or upstream rosdep) long-term.

But that’s not going to fix this:

You’re correct, rosdep doesn’t seem to have a rule for a Python 3 version of open3d. I suggest adding one.

Before you continue further down this path though, I want to reiterate a specific point:

Snapcraft changed how it did things for Noetic, and it currently is missing the magic that will take care of rosdep pip dependencies for you. I really recommend sticking with Melodic and embracing Python 2 for now if you can stand it, but that’s definitely a feature we need to add. Overall you can see that Python 3 is a pretty new look for ROS 1, and it still needs some creases ironed out.

I’m applying the changes you suggested.

I’m waiting for the pull-request confirmation. The rosdep worked at my local sources.list.d (here I see there’s not a way to test it with a local list).

While I’m waiting, I test again the snapcraft with the build-package recommendation:

parts:
  sick-app-workspace:
    # See 'snapcraft plugins'
    plugin: catkin
    source: .
    build-packages: [python3-pip]
    catkin-packages: [sick_app]
apps:
  sick:
    command: roslaunch sick_app sick_sensor.launch
    plugs: [network, network-bind]
    extensions: [ros1-noetic]

  filter:
    command: roslaunch sick_app node_filter.launch
    plugs: [network, network-bind]
    extensions: [ros1-noetic]

  model:
    command: roslaunch sick_app model_server.launch
    plugs: [network, network-bind]
    extensions: [ros1-noetic]

but now I have the following error, it’s kind weird to me, since I thought the launch executables were already included at CmakeList.txt

Priming sick-app-workspace 
+ snapcraftctl prime
This part is missing libraries that cannot be satisfied with any available stage-packages known to snapcraft:
- libjawt.so
- usr/lib/x86_64-linux-gnu/libpsm_infinipath.so.1
These dependencies can be satisfied via additional parts or content sharing. Consider validating configured filesets if this dependency was built.
Failed to generate snap metadata: The specified command 'roslaunch sick_app sick_sensor.launch' defined in the app 'sick' does not exist.
Ensure that 'roslaunch sick_app sick_sensor.launch' is installed with the correct path.

Should I add the libjawt.so and usr/lib/x86_64-linux-gnu/libpsm_infinipath.so.1 to the stage-packages?

Thanks for your recommendation. In this moment, I need to use open3d which is new only works at python3, so for the moment I’m forcet to build with Noetic.

You installed launch FILES, but you still need roslaunch in the snap in order to launch them. You’ll note this was working in your previous Melodic snap, and it’s not in Noetic, because snapcraft got a lot smarter. It comes down to this:

You’re saying your package requires roslaunch to build, but not run. If you install launch files, they cannot run without roslaunch, so you might want to make it an exec depends. And I’m trying to reason out why you’d need roslaunch to build, you might double check that.

Try doing nothing first, I have seen those as well and they don’t seem to cause issues, I haven’t managed to get to the bottom of it. I suspect it’s related to a ROS plugin somewhere that doesn’t properly declare dependencies.

I already had the build_depend for roslaunch at package.xml because I’m using roslaunch_add_file_check into the CMakeList.txt. You’re right, I added both exec and build depend. But It failed with the same error.

Also I tried removing the roslaunch_add_file_check, and only using the <exec_depend>roslaunch</exec_depend> but it also fails.

Alright I think we’re just about there. Instead of this:

Try providing the relative path (from the root of the snap) to the binary: Something like:

apps:
  sick:
    command: opt/ros/noetic/bin/roslaunch sick_app sick_sensor.launch

Hi @kyrofa

It works perfectly.

Then, I’ve got this error (As I see, this is a “typicall” error ) with libblas.so.3 and liblapack.so.3. So after reviewing the forum topics, I achieved to this solution that works for me:

parts:
  sick-app-workspace:
    plugin: catkin
    source: .
    build-packages: [python3-pip]
    catkin-packages: [sick_app]
    stage-packages: 
      - libblas-dev 
      - liblapack-dev
      - liblapack3
      - libblas3
    override-build: |
      snapcraftctl build
      set -ex
      for dir in $SNAPCRAFT_PART_INSTALL/usr/lib/*/; do
        (cd $dir;
        if [ -f blas/libblas.so.3.* ]; then
          ln -s blas/libblas.so.3.* libblas.so.3
        fi)
      done
apps:
  ...
  model:
    command: opt/ros/noetic/bin/roslaunch sick_app model_server.launch
    plugs: [network, network-bind]
    extensions: [ros1-noetic]
    environment: 
      LD_LIBRARY_PATH: "$LD_LIBRARY_PATH:$SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/blas:$SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/lapack"

Now, I’m facing the Open3D import error:

Traceback (most recent call last):
  File "/snap/sick-snap-noetic/x1/opt/ros/noetic/lib/sick_app/model_classifier.py", line 17, in <module>
    import open3d as o3d
ModuleNotFoundError: No module named 'open3d'

As you suggested, I made a pull-request to add a python3 rule of open3d. I’ve been waiting the merge since the last week, idk if it will take longer… Is there any way to snap the package with my local rosdep rules? (i.e. from my local python.yaml or from my github personal fork).

Edit: I’m planning to follow this approach (It seems to be similar to the solution you specified here). But at the Snapcraft 4.0 release notes says the core20 is now using the plugins V2, which changes a little bit the situation. After a quick search at plugins/v2 dir, I found this (at line 125):

def get_build_commands(self) -> List[str]:
    return (
        self._get_workspace_activation_commands()
        + [
            "if [ ! -f /etc/ros/rosdep/sources.list.d/20-default.list ]; then sudo rosdep init; fi",
            "rosdep update --include-eol-distros --rosdistro $ROS_DISTRO",
            "rosdep install --default-yes --ignore-packages-from-source --from-paths $SNAPCRAFT_PART_SRC",
        ]
        + self._get_build_commands()
        + self._get_stage_runtime_dependencies_commands()
    )

I’m not familiar with the [ ] script, but I understand that it verifies the 20-default.list file, and if it isn’t there, it runs rosdep init. I tried editing directly the 20-default.list file to read a local python.yaml file. It works for my local ROS packages, but the snapcraft build failed, I asume it is still executing rosdep init according to this:

+ '[' '!' -f /etc/ros/rosdep/sources.list.d/20-default.list ']'
+ rosdep update --include-eol-distros --rosdistro noetic
reading in sources list data from /etc/ros/rosdep/sources.list.d
Warning: running 'rosdep update' as root is not recommended.
  You should run 'sudo rosdep fix-permissions' and invoke 'rosdep update' again without sudo.
Hit https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/osx-homebrew.yaml
Hit https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/base.yaml
Hit https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/python.yaml
Hit https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/ruby.yaml
Hit https://raw.githubusercontent.com/ros/rosdistro/master/releases/fuerte.yaml
Query rosdistro index https://raw.githubusercontent.com/ros/rosdistro/master/index-v4.yaml
Skip distro "ardent" different from requested "noetic"
Skip distro "bouncy" different from requested "noetic"
Skip distro "crystal" different from requested "noetic"
Skip distro "dashing" different from requested "noetic"
Skip distro "eloquent" different from requested "noetic"
Skip distro "foxy" different from requested "noetic"
Skip distro "groovy" different from requested "noetic"
Skip distro "hydro" different from requested "noetic"
Skip distro "indigo" different from requested "noetic"
Skip distro "jade" different from requested "noetic"
Skip distro "kinetic" different from requested "noetic"
Skip distro "lunar" different from requested "noetic"
Skip distro "melodic" different from requested "noetic"
Add distro "noetic"
Skip distro "rolling" different from requested "noetic"
updated cache in /root/.ros/rosdep/sources.cache
+ rosdep install --default-yes --ignore-packages-from-source --from-paths /root/parts/sick-app-workspace/src
ERROR: the following packages/stacks could not have their rosdep keys resolved
to system dependencies:
sick_app: Cannot locate rosdep definition for [python3-open3d-pip]

You’re doing the right thing adding that rule, but as I mentioned earlier it’s not all you’re going to need if you want snapcraft to use your pip dependencies with Noetic:

Barring that support (we’ll look to get it in next cycle) you might be able to get away with a strategy similar to what you were taking earlier: comment out the open3d dep in the package.xml and add another python part that pulls it in via python-packages. If that doesn’t work, then you can go the nuclear route and rosify open3d, pulling it into your workspace and writing a package.xml for it.

Okay, I didn’t take into account that change you mentioned previously for noetic… I tried adding the python3 part, and it showed the

Failed to stage: Parts 'sick-app-workspace' and 'python-part' have the following files, but with different contents:
    lib64

So I followed the solution mentioned here

 stage:
      - lib64/*

But the prime fails because the python-part part has a lot of missing libraries

The 'python-part' part is missing libraries that are not included in the snap or base. They can be satisfied by adding the following entry for this part
stage-packages:
- libgl1
- libglvnd0
- libglx0
- libgomp1
- libusb-1.0-0
- libx11-6
- libxau6
- libxcb1
- libxdmcp6
This part is missing libraries that cannot be satisfied with any available stage-packages known to snapcraft:
- libc10.so
- libc10_cuda.so
- libcublas.so.10
- libcudart.so.10.1
- libcusolver.so.10
- libnvToolsExt.so.1
- libtensorflow_framework.so.2
- libtorch.so
- libtorch_cpu.so
- libtorch_cuda.so
These dependencies can be satisfied via additional parts or content sharing. Consider validating configured filesets if this dependency was built.
The execstacks are going to be cleared for the following files:
- /root/prime/lib/python3.8/site-packages/open3d/cuda/pybind.cpython-38-x86_64-linux-gnu.so
- /root/prime/lib/python3.8/site-packages/open3d/cpu/pybind.cpython-38-x86_64-linux-gnu.so
To disable this behavior set `build-attributes: [keep-execstack]` for the part.

Before I import those libraries into stage-packages , I would like to know if it is a good way to solve the open3d issue…

I may be speaking out of turn here, as I don’t know anything about ROS. That being said, however, it’s generally better for “most” Snaps to install the library packages directly instead of their -dev counterparts to reduce the size of the final Snap package a bit. I think you can drop the libblas-dev and liblapack-dev packages from stage-packages. Though you might still need those two packages in build-packages for your app to correctly build if you’re compiling anything:

parts:
  sick-app-workspace:
    ...
    build-packages:
    - libblas-dev
    - liblapack-dev
    stage-packages:
    - libblas3
    - liblapack3
    ...

Thanks for your response Daniel.
I tested your suggestion an it works for the stage and build packages. But the snap size didn’t change.