niess/python-appimage

pip is missing when venv is created out of appimage

py-radicz opened this issue · 2 comments

~ ./python3.9.9-cp39-cp39-manylinux2010_x86_64.AppImage -m venv venvs/test
 △ ~ venvs/test/bin/python -m pip
/home/keskfrad/venvs/test/bin/python: No module named pip

is it even possible to create and use virtual envs out of such .AppImages?

niess commented

Hi. In order to get pip in the venv you can do

. venvs/test/bin/activate
python -m ensurepip

For some reason, the venv setup script fails to directly fetch pip. I don't remember why exactly.

Note that I am not using venv. Thus, there might be other limitations?

Actually, the appimage is self contained and could be used as an independent Python instance. You can extract the content to a local directory, and then you can pip install to the extracted directory. For example, like this:

./python3.9.9-cp39-cp39-manylinux2010_x86_64.AppImage --appimage-extract
mv squashfs-root/ python3.9.9-cp39-cp39-manylinux2010_x86_64.AppDir
 ./python3.9.9-cp39-cp39-manylinux2010_x86_64.AppDir/AppRun -m pip install numpy
ls python3.9.9-cp39-cp39-manylinux2010_x86_64.AppDir/opt/python3.9/lib/python3.9/site-packages/numpy

Note that of course you could symlink to the extracted AppRun, or use more simple directory names :P

It is also possible to build a new AppImage from the modified extracted one, e.q. using appimagetool, and then redistribute it. This is actually what the python-appimage package does.

ensurepip module solved my problem!