How to set PYTHONHOME for modules installed by pip?

I am on Linux and use the expanded appimage.

Before I run ./AppRun in the topmost appimage folder, I had to set PYTHONHOME:

export PYTHONHOME=./usr

Everyting works fine.

However, if I use a Python module that I installed via pip in

/home/nst0022/.local/lib/python3.9/site-packages

this module is not found by Krita, because it does not know this path.

I tried to append this path to PYTHONHOME:

export PYTHONHOME=./usr:/home/nst0022/.local/lib/python3.9/site-packages

but this simply cashes the scripter.

I also tried to append the path to PYTHONPATH:

export PYTHONPATH=$PYTHONPATH:/home/nst0022/.local/lib/python3.9/site-packages

but this crashes the scripter as well.

What do I have to do?

Hi

If it can help you:

Grum999

2 Likes

If I understand your thread correctly, then you install pip modules within Krita

Okay, this would mean, that I had to maintain duplicate pip modules

Good enough as a workaround

However, your

Modules installed from pip are located in ~/.local/share/krita/pykrita/piplib directory (so, it’s local to user’s Krita installation)

brought me to the idea, on a trial-and-error basis, to just put a softlink to the required module, like:

cd ~/.local/share/krita/pykrita
ln ~/.local/lib/python3.9/site-packages/yaml/

Surprisingly, this worked

I will keep this workaround for the time being, although the above mentioned “export” would be a more elegant solution, if it worked :smile:

Hi

Yes :slight_smile:

Just take care:

  • Python version embedded with appimage may not be the same than one installed on your system
  • Pip version used on your system may not be the same than one installed within Krita

So, you’ve a risk to get pip modules (installed from OS) not compatible with PyKrita
(if you have Python 3.10 on your system and a pip library is available for python 3.10, it will be installed but probably not compatible with Krita if there’s specific python 3.10 statements in code)

Grum999

1 Like

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.