Hi,
I’m trying to package a python tool that uses the opencv and gexiv2 (via gobject-introspection) bindings.
My snapcraft.yaml file looks like:
name: pictool
version: git
grade: devel
summary: command line program for manipulating and altering images
description: |
pictool is a command line program for manipulating and altering images.
base: core20
confinement: strict
parts:
pictool:
plugin: python
source: .
python-packages:
- pip
- setuptools
- wheel
stage-packages:
- python3-pbr
- python3-opencv
- opencv-data
- gir1.2-gexiv2-0.10
apps:
pictool:
command: bin/pictool
When I install the snap and try to run pictool
, I get:
$ pictool
debugging sys.path: ['/snap/pictool/x12/bin', '/usr/lib/python38.zip', '/usr/lib/python3.8', '/usr/lib/python3.8/lib-dynload', '/snap/pictool/x12/lib/python3.8/site-packages']
Traceback (most recent call last):
File "/snap/pictool/x12/bin/pictool", line 5, in <module>
from pictool import main
File "/snap/pictool/x12/lib/python3.8/site-packages/pictool/__init__.py", line 28, in <module>
import pictool.utils_opencv as utils_opencv
File "/snap/pictool/x12/lib/python3.8/site-packages/pictool/utils_opencv.py", line 23, in <module>
import cv2
ModuleNotFoundError: No module named 'cv2'
The first line show sys.path
for debugging.
Looking at the content from the snap, the needed cv2 import is located at
/snap/pictool/current/usr/lib/python3/dist-packages/
:
$ ls -al /snap/pictool/current/usr/lib/python3/dist-packages/
total 6808
drwxr-xr-x 7 root root 158 Dez 15 21:53 .
drwxr-xr-x 3 root root 36 Dez 15 21:53 ..
-rw-r--r-- 1 root root 6970496 Feb 18 2020 cv2.cpython-38-x86_64-linux-gnu.so
drwxr-xr-x 3 root root 32 Dez 15 21:53 gi
drwxr-xr-x 15 root root 433 Dez 15 21:53 numpy
drwxr-xr-x 2 root root 124 Dez 15 21:53 numpy-1.17.4.egg-info
drwxr-xr-x 5 root root 298 Dez 15 21:53 pbr
drwxr-xr-x 2 root root 124 Dez 15 21:53 pbr-5.4.5.egg-info
but this directory is not in the python path.
Is that a bug of the python module? Should I set PYTHONPATH
somehow?