Page MenuHomePhabricator

libopenjp2.so.7 is missing on toolforge jobs framework
Closed, InvalidPublicBUG REPORT

Description

Steps to replicate the issue (include links if applicable):

  • Become your tool account on bastion
  • Create a python environment: python3 -m venv /path/to/env
  • Activate the environment: . /path/to/env/bin/activate
  • Install Pillow: python3 -m pip install Pillow
  • Save the script provided below in a file located at /path/to/script.py
script.py
from PIL import Image
  • Save the following script in a file located at /path/to/wrapper.sh
wrapper.sh
. ~/env/bin/activate
python3 ~/path/to/script.py
deactivate
  • First run the wrapper script directly on Bastion: . /path/to/wrapper.sh
  • Now create a job on toolforge job framework to run the same wrapper script:
tfj run "testpillow" --command ~/path/to/wrapper.sh -e ~/path/to/wrapper.log -o ~/path/to/wrapper.log --image tf-python37

What happens?:
Running the command on Bastion succeeds.

Running the command as a job results in an error message that is similar to this:

Traceback (most recent call last):
  File "/data/project/huji/core/pwb.py", line 39, in <module>
    sys.exit(main())
  File "/data/project/huji/core/pwb.py", line 35, in main
    runpy.run_path(str(path), run_name='__main__')
  File "/usr/lib/python3.7/runpy.py", line 263, in run_path
    pkg_name=pkg_name, script_name=fname)
  File "/usr/lib/python3.7/runpy.py", line 96, in _run_module_code
    mod_name, mod_spec, pkg_name, script_name)
  File "/usr/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/data/project/huji/core/pywikibot/scripts/wrapper.py", line 513, in <module>
    main()
  File "/data/project/huji/core/pywikibot/scripts/wrapper.py", line 497, in main
    if not execute():
  File "/data/project/huji/core/pywikibot/scripts/wrapper.py", line 484, in execute
    run_python_file(filename, script_args, module)
  File "/data/project/huji/core/pywikibot/scripts/wrapper.py", line 148, in run_python_file
    main_mod.__dict__)
  File "/data/project/huji/core/scripts/userscripts/test_pillow.py", line 4, in <module>
    from PIL import Image
  File "/data/project/huji/env/lib/python3.7/site-packages/PIL/Image.py", line 132, in <module>
    from . import _imaging as core
ImportError: libopenjp2.so.7: cannot open shared object file: No such file or directory
CRITICAL: Exiting due to uncaught exception ImportError: libopenjp2.so.7: cannot open shared object file: No such file or directory

What should have happened instead?:
The wrapper script should run without errors when executed on toolforge jobs framework

Other information (browser name/version, screenshots, etc.):
Essentially, the Pillow python package is failing to run, due to a missing dependency.

According to Stack Overflow this can be fixed by running sudo apt install libopenjp2-7 on the machine that is running the script.

Event Timeline

JJMC89 subscribed.

It works for me if you follow the instructions at Help:Toolforge/Python#Jobs and create the venv using a job.

$ cat $HOME/bootstrap_venv.sh
#!/bin/bash

# use bash strict mode
set -euo pipefail

# delete the venv, if it already exists
rm -rf pyvenv

# create the venv
python3 -m venv pyvenv

# activate it
source pyvenv/bin/activate

# upgrade pip inside the venv and add support for the wheel package format
pip install -U pip setuptools wheel

pip install Pillow
$ chmod ug+x bootstrap_venv.sh
$ toolforge jobs run bootstrap-venv --command "$HOME/bootstrap_venv.sh" --image python3.7 --wait
INFO: job 'bootstrap-venv' completed
$ cat bootstrap-venv.*
Collecting pip
  Using cached https://files.pythonhosted.org/packages/8a/6a/19e9fe04fca059ccf770861c7d5721ab4c2aebc539889e97c7977528a53b/pip-24.0-py3-none-any.whl
Collecting setuptools
  Using cached https://files.pythonhosted.org/packages/c7/42/be1c7bbdd83e1bfb160c94b9cafd8e25efc7400346cf7ccdbdb452c467fa/setuptools-68.0.0-py3-none-any.whl
Collecting wheel
  Using cached https://files.pythonhosted.org/packages/c7/c3/55076fc728723ef927521abaa1955213d094933dc36d4a2008d5101e1af5/wheel-0.42.0-py3-none-any.whl
Installing collected packages: pip, setuptools, wheel
  Found existing installation: pip 18.1
    Uninstalling pip-18.1:
      Successfully uninstalled pip-18.1
  Found existing installation: setuptools 40.8.0
    Uninstalling setuptools-40.8.0:
      Successfully uninstalled setuptools-40.8.0
Successfully installed pip-24.0 setuptools-68.0.0 wheel-0.42.0
Collecting Pillow
  Using cached Pillow-9.5.0-cp37-cp37m-manylinux_2_28_x86_64.whl (3.4 MB)
Installing collected packages: Pillow
Successfully installed Pillow-9.5.0
$ cat wrapper.sh
. ~/pyvenv/bin/activate
python3 ~/script.py
deactivate
$ chmod +x wrapper.sh
$ cat script.py
from PIL import Image
$ toolforge jobs run testpillow --command ~/wrapper.sh --image python3.7 --wait
INFO: job 'testpillow' completed
$ cat testpillow.*  # no output -- success