04-03-2025, 07:46 PM
I'm trying to get a bash script to run after changing folders.
If I explicitly set the path to the python scripts it runs fine.
If I however omit the explicit path, even though the scripts are in my PYTHONPATH they are not recognized when running without
explicitly using sys.path.append
If I try and get the python path from inside the Gimp shell, it reports no key present instead of printing the PYTHONPATH like it does when not in the Gimp shell.
As stated in the title I have the flatpak version so my question is how do I get it to use my current PYTHONPATH?
Also is it possible to use packages, and if so how. I had a simple package, but when functions were called from a bash script, they would fail with the internal imports in the package failing. An example is below:
However if on the command line I load a python script that calls the same methods as the bash script it executes fine.
I feel like it's something simple i'm missing because I'm not a python programmer. Hopefully someone can help.
Thanks.
If I explicitly set the path to the python scripts it runs fine.
If I however omit the explicit path, even though the scripts are in my PYTHONPATH they are not recognized when running without
explicitly using sys.path.append
If I try and get the python path from inside the Gimp shell, it reports no key present instead of printing the PYTHONPATH like it does when not in the Gimp shell.
As stated in the title I have the flatpak version so my question is how do I get it to use my current PYTHONPATH?
Also is it possible to use packages, and if so how. I had a simple package, but when functions were called from a bash script, they would fail with the internal imports in the package failing. An example is below:
Code:
### This should be the command to start Gimp
GIMP_THREE='flatpak run --user org.gimp.GIMP'
# Start gimp with python-fu batch-interpreter
$GIMP_THREE -i --batch-interpreter=python-fu-eval -b - << EOF
import os
import sys
print("PYTHONPATH = " + os.environ['PYTHONPATH'])
EOF
exit(0)
However if on the command line I load a python script that calls the same methods as the bash script it executes fine.
Code:
flatpak run --user org.gimp.GIMP -i --batch-interpreter=python-fu-eval -b 'import sys; sys.path=["."]+sys.path;import pytest;pytest.run()'
I feel like it's something simple i'm missing because I'm not a python programmer. Hopefully someone can help.
Thanks.