SOLVED Handling python dependencies
Hello everyone, Im currently writing an app that uses some python libraries I installed using pip3, everything works on my pc and I would now like to package it using clickable, but I have no idea how I can add those libraries to my build. Any tipps on how to do that? thanks already.
@aarontheissueguy There are a few ways - all include copying the modules into the package. This should be very easy if you are using a virutalenv, because ideally all the packages required are installed in it (and hopefully no others, because that would be a bit of a waste of space).
The simplest way is to copy all the folders into the main package folder (i.e. in the same folder as the Python files) since Python will automatically look for the modules in that folder, so it should find them. Note that any modules that have binary files that are specific to one arch will fail on the other arches.
Another method is to use the
PYTHONPATH(https://docs.python.org/3/using/cmdline.html#envvar-PYTHONPATH) environment variable to point to the folder containing the modules. This can also be done in Python by adding the following to the top of your Python files:
import sys sys.path.append('<PATH>')
This will make Python look for the modules in the provided path.
@abmyii Thank you for the response. Yes I am working in a virtual environment. I added the lib and bin folder to the CmakeList and added them to path like this in Python:
import sys sys.path.append('../bin') sys.path.append('../lib') import Agunua from io import StringIO import io
This still results in an error if I run clickable desktop though
@aarontheissueguy Do you have the project hosted online? It's a bit difficult to debug without understanding the structure. If it's not hosted online, running
treeshould be enough for me to get an idea of the structure.
@aarontheissueguy I see. So I think the problem here is that the libs are in the
lib/Python3.8folder as opposed to directly in the
lib/folder. Try either moving them into the
lib/folder or adding
@abmyii I was able to import properly thanks.
@aarontheissueguy Great news!
Just to explain the solution if someone stumbles across this with the same question:
use sys to add "lib/python3.8/site-packages" to path. note that you not need to "../" out of the src directory. The end result looks like this:
import sys sys.path.append('lib/python3.8/site-packages')
You might need to change the Python version