Install packages on runtime, pip --user

Hi,

I want my program to be able to install python packages on runtime, as plugins might need additional packages that I won’t know of when building my app.

How can I do this? I’ve tried using the --user flag in my app, but I get this error:

ERROR: Can not perform a ‘–user’ install. User site-packages are not visible in this virtualenv.

Any idea how I can overcome this “issue”? I’m aware that Snaps are running in an isolated environment (RO file system), but is there any other way that a Snap app can run pip and store packages e.g in SNAP_USER_DATA (alt. SNAP_DATA)?