Page MenuHomePhabricator

[apt-buildpack] Set PYTHONPATH whenever python packages are installed
Closed, ResolvedPublic

Description

Currently PYTHONPATH is not modified, but if you install a custom python package the install directory is not in the path, so it fails to load them.

Event Timeline

dcaro changed the task status from Open to In Progress.Feb 2 2024, 11:58 AM
dcaro moved this task from Next Up to In Progress on the Toolforge (Toolforge iteration 04) board.

This was not all that's needed, as numy for example will fail to load the compiled extensions :/

heroku@8ffd1f604c73:/workspace$ python
Python 3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
Traceback (most recent call last):
  File "/layers/fagiani_apt/apt/usr/lib/python3/dist-packages/numpy/core/__init__.py", line 22, in <module>
    from . import multiarray
  File "/layers/fagiani_apt/apt/usr/lib/python3/dist-packages/numpy/core/multiarray.py", line 12, in <module>
    from . import overrides
  File "/layers/fagiani_apt/apt/usr/lib/python3/dist-packages/numpy/core/overrides.py", line 7, in <module>
    from numpy.core._multiarray_umath import (
ImportError: libblas.so.3: cannot open shared object file: No such file or directory

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/layers/fagiani_apt/apt/usr/lib/python3/dist-packages/numpy/__init__.py", line 150, in <module>
    from . import core
  File "/layers/fagiani_apt/apt/usr/lib/python3/dist-packages/numpy/core/__init__.py", line 48, in <module>
    raise ImportError(msg)
ImportError: 

IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!

Importing the numpy C-extensions failed. This error can happen for
many reasons, often due to issues with your setup or how NumPy was
installed.

We have compiled some common reasons and troubleshooting tips at:

    https://numpy.org/devdocs/user/troubleshooting-importerror.html

Please note and check the following:

  * The Python version is: Python3.10 from "/usr/bin/python"
  * The NumPy version is: "1.21.5"

and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.

Original error was: libblas.so.3: cannot open shared object file: No such file or directory

>>>

Looking on adding the missing paths to LD_LIBRARY_PATH too

Adding an overextended LD_LIBRARY_PATH allows loading numpy:

heroku@473c113710f3:/workspace$ python
Python 3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
>>>
dcaro moved this task from In Progress to Done on the Toolforge (Toolforge iteration 04) board.

Rolled out the fix