Skip to content

_ensure_critical_deps() never gets called #8846

Description

@aerobio

Reporting a bug

  • I have tried using the latest released version of Numba.
  • I have included a self contained code sample to reproduce the problem.

My library uses Numpy and Numba. All works as expected when using a compatible Numpy version.

I rely on ImportError being raised when importing Numba while an incompatible Numpy version is installed. Then, I can disable Numba and warn the user (recommending to downgrade Numpy, for example).

I recently upgraded my library and found that ImportError is no longer raised when an incompatible Numpy version is installed. Instead, a SystemError is raised while importing _internal from numba/__init__.py, so _ensure_critical_deps() doesn't get called:

$ python
Python 3.8.10 (default, Mar 13 2023, 10:26:41) 
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import numba
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/jotaele/Devel/pygeomy/venv_nb/lib/python3.8/site-packages/numba/__init__.py", line 42, in <module>
    from numba.np.ufunc import (vectorize, guvectorize, threading_layer,
  File "/home/jotaele/Devel/pygeomy/venv_nb/lib/python3.8/site-packages/numba/np/ufunc/__init__.py", line 3, in <module>
    from numba.np.ufunc.decorators import Vectorize, GUVectorize, vectorize, guvectorize
  File "/home/jotaele/Devel/pygeomy/venv_nb/lib/python3.8/site-packages/numba/np/ufunc/decorators.py", line 3, in <module>
        from numba.np.ufunc import _internal
SystemError: initialization of _internal failed without raising an exception

I used the following minimal environment to reproduce the problem:

Ubuntu 20.04 LTS
Python 3.8.10

Package            Version
------------------ -------
importlib-metadata 6.1.0
llvmlite           0.39.1
numba              0.56.4
numpy              1.24.2
pip                23.0.1
setuptools         67.6.0
wheel              0.40.0
zipp               3.15.0

As a workaround I'm solving the problem by catching also SystemError while attempting to import Numba. But it doesn't provide the root cause (as _ensure_critical_deps() did) so I can't advice the user on how to solve the problem.

Activity

  1. gmarkall commented on Mar 24, 2023

    @gmarkall
    Member

    These issues are already resolved on main and will be part of the 0.57 release (RC coming soon):

    Once the RC is out (which will be announced on https://numba.discourse.group), could you please check that all is well with your use case?

    Alternatively, you could check with a build of Numba from main right away, but it might be worth waiting just to save yourself the effort of fiddling about to get a build off main.

  2. gmarkall commented on Mar 24, 2023

    @gmarkall
    Member

    (Closing as duplicate of #8615)

  3. aerobio commented on Mar 24, 2023

    @aerobio
    Author

    Excellent, thank you for the quick response!
    Sorry I couldn't identify #8615 as the same issue.

  4. gmarkall commented on Mar 24, 2023

    @gmarkall
    Member

    No problem 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions