HLA python import

I am trying to import modules installed via pip in a HLA.

TL;DR: Its an issue with the python version. Logic bundle a python3.8 while my system uses python3.10. Installing modules with python3.8 makes it work.

I have read this topic: Import other libraries in HLA (and a few others), but I can’t get it to work.
I have however some differences that can explain it does not work:

  • I am on linux, running Logic with the AppImage.
  • My “usual” python is python 3.10, and it seems that the python bundled in the AppImage is python3.8

I tried installing the lxml module, and this works:
import lxml
But this does not:
from lxml import etree

I tried moving the lib folder around but it does not change the behavior.
I think installing the libraries with my python3.10 is problematic since Logic uses python3.8.

Can you recommend me a way to install dependencies from Pypi on linux?

Also, would it be possible to give the ability to change the python executable used by Logic?
It would be so much simple if we could just use our own system python, or a venv.
For the record, this is how I did it with the C API for a project of mine:

PyConfig config;
PyConfig_SetString(&config, &config.program_name, "/path/to/python3");

This python3.8 vs python3.10 thing really bothered me, so I installed python3.8, and install the library in lib with python3.8, and now it works.
But this is really not convenient, as it force the user to install the correct python version.
It would be really great to be able to use a venv, or to list pypi dependencies in the extension.json

Best regards

@fabien.bonneval Sorry for the trouble that caused. I recall one other user recently that I spoke to that had a similar issue with regards to python versioning. Long story short, Python versioning is a bit of a mess. It’s really easy to use different installs across different commands without realizing it as well. I’ll get this on our discussion list to see if we can find a way to work around this issue. At the very least, we’ll likely need to add some notes about this in the troubleshooting section of the API docs.

I just wanted to add that we do want to get this solved. Right now we just don’t officially support loading other python packages, mainly because we haven’t decided exactly how we want that to work with the marketplace. We’ll likely end up with some sort of solution where every extension will have its own virtual environment, and we will limit each extension to only load packages from within the virtual environment. It’s going to be a good bit of work on our end and we won’t be able to get back to the next version of extensions for some time, unfortunately.

We will try to help where we can in the interim, to help users get this working for their local extensions. Just be sure not to publish any extensions that depend on external packages.

I my case, the annoying thing was that I had to install python3.8 on my system.
A “good” short-term solution might be to enable access to the python used internally by Logic.
It could be from a terminal inside Logic, or when launching the Logic executable with the correct option.
./Logic.AppImage --python -- pip install -r requirements.txt --target lib

I imagine the AppImage bundling add a bit more challenges to this.