How to reference local libraries in snapcraft.yaml

Hi everyone

I’m trying to builda snap package for eXeLearning Project (https://github.com/exelearning/iteexe).

At last, I managed to create the snap package, but when trying to run the application after install it, it doesn’t work. I get the following error:
ImportError: No module named twisted.internet

This library (Twisted) is inside the code in their own folder, I dont´t need to add it to requirements.txt. But the project can`t locate it.

How I can reference where is located my local libraries in the snapcraft.yaml file?

Thanks in advance.

You can see my snapcraft.yaml here: [https://pastebin.com/etxMtacQ]

try adding

    environment:
      PYTHONPATH: $SNAP/lib:$SNAP/usr/lib:$PYTHONPATH

under your command: line in the snapcraft.yaml, so python looks in the right places at runtime.

1 Like

It seems that it works! Thanks a lot.

Now, I get another error:

OSError: [Errno 30] Read-only file system: '/snap/exelearning/x1/bin/config'

I think that i have to specify a folder for user data where the app can write. It can`t write in this location:
/snap/exelearning/x1/bin/config

Can I choose a folder for user config folder? How? (maybe would be better to open another thread to ask about this problem).

have a look at:

I was checking that post, but I couldn’t understand how to do it.

I have a config file (/snap/exelearning/x1/bin/config), but I notice that I can’t place in that location because is an onlyreadable folder.

I need to link or hook mi config file to another location where I can write (i.e. in root home folder [/root]), but i don’t know to to do thath in my snapcraft.yaml.

well, the post i referenced discusses where you have writeble dirs you can access from a snap via environment variables (SNAP_DATA and SNAP_USER_DATA) …

there is a follow up one that discusses this more in detail: