Skip to content
Valentin edited this page Jun 5, 2019 · 1 revision

Here you will find more detailed instructions for end-users

Installation

  1. Download a Python AppImage from the release area, E.g python3-x86_64.AppImage.

  2. Make the image executable, E.g:

    chmod u+x python3-x86_64.AppImage
    

Note that here is no 3. The AppImage can be readily used as so, as a standard python binary. For, example to start a session:

> ./python3-x86_64.AppImage
Python 3.7.3 (default, Jun  7 2019, 19:11:26) 
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 

Usage

There are several schemes (workflows) that you can follow using the Python AppImage.

The --user scheme (novice)

Any Python executable package installed inside the AppImage is accessible using the classical -m option, E.g.:

./python3-x86_64.AppImage -m pip install pip --user --upgrade

Note that since the AppImage is read-only, extra packages or upgrades must be installed following the --user scheme, i.e. to your $HOME. If you follow this workflow you'd probably create wrappers or aliases for common commands, E.g. pip.

The virtual env scheme (medium)

Using a Python 3 AppImage you can create a virtual env from the downloaded image, E.g. as:

./python3-x86_64.AppImage -m venv ENV

Then, one can follow the usual workflow with a virtual env. Note that there are two caveats though:

  • Only venv is supported, limiting this functionality to Python 3. The design of virtualenv makes it difficult to run from an AppImage.

  • venv does not manage to install pip when creating the virtual environment. This can however be done afterwards, from within the env as:

    [ENV] > python -m ensurepip
    

The embeded scheme (expert)

The AppImage can be used as an engine in order to power a Python based project, a framework or simply a clean workspace. One can get a relocatable and isolated higher level application by using the following layout:

Application/
  - bin/
    - pythonX.AppImage
  - lib/pythonX.Y/site-packages/
  - user/
    - bin
    - lib/pythonX.Y/site-packages/

By following this layout, Python will search and install any extra packages in the created site-packages directories. Executable scripts will be installed to the bin/ directories, which must be added to your $PATH.

Note that the user/ directory is optional. There can be several as well, E.g. grouped in a home/ directory below Application/. By providing a user/ and starting python with HOME=/path/to/user one creates an isolated user space, E.g. for installing separated packages with the --user scheme.

The whole Application directory can be relocated (distributed), provided that the site packages are relocatable. There is one extra caveat: the shebangs (#!) created by Python, when installing a script, are absolute. This can however easily be fixed by substititing them, E.g. with a setup.sh script that would also configure the environment ($PATH, $HOME, ...).

Clone this wiki locally