#399·LaTeX-OCR

Incompatibility with Numpy2.0

Author: r-menezesCreated Oct 7, 2024Updated Jul 20, 2025

Hi, LaTeX-OCR is a blessing! Thank you so much for making it available. After upgrading my conda installation, I found the following problem related to the usage of an older version of numpy that does not seem to be supported:

A module that was compiled using NumPy 1.x cannot be run in NumPy 2.1.1 as it may crash. To support both 1.x and 2.x versions of NumPy, modules must be compiled with NumPy 2.0. Some module may need to rebuild instead e.g. with 'pybind11>=2.12'.

If you are a user of the module, the easiest solution will be to downgrade to 'numpy<2' or try to upgrade the affected module. We expect that some modules will need time to support NumPy 2.

Full traceback:

bash
Traceback (most recent call last):  File "/home/rafael/micromamba/bin/latexocr", line 8, in <module>
    sys.exit(main())
  File "/home/rafael/micromamba/lib/python3.12/site-packages/pix2tex/__main__.py", line 25, in main
    from .gui import main
  File "/home/rafael/micromamba/lib/python3.12/site-packages/pix2tex/gui.py", line 18, in <module>
    from pix2tex import cli
  File "/home/rafael/micromamba/lib/python3.12/site-packages/pix2tex/cli.py", line 1, in <module>
    from pix2tex.dataset.transforms import test_transform
  File "/home/rafael/micromamba/lib/python3.12/site-packages/pix2tex/dataset/transforms.py", line 1, in <module>
    import albumentations as alb
  File "/home/rafael/micromamba/lib/python3.12/site-packages/albumentations/__init__.py", line 3, in <module>
    from .augmentations import *
  File "/home/rafael/micromamba/lib/python3.12/site-packages/albumentations/augmentations/__init__.py", line 1, in <module>
    from .blur.functional import *
  File "/home/rafael/micromamba/lib/python3.12/site-packages/albumentations/augmentations/blur/__init__.py", line 1, in <module>
    from .functional import *
  File "/home/rafael/micromamba/lib/python3.12/site-packages/albumentations/augmentations/blur/functional.py", line 5, in <module>
    import cv2
  File "/home/rafael/micromamba/lib/python3.12/site-packages/cv2/__init__.py", line 181, in <module>
    bootstrap()
  File "/home/rafael/micromamba/lib/python3.12/site-packages/cv2/__init__.py", line 153, in bootstrap
    native_module = importlib.import_module("cv2")
  File "/home/rafael/micromamba/lib/python3.12/importlib/__init__.py", line 90, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
AttributeError: _ARRAY_API not found
Traceback (most recent call last):
  File "/home/rafael/micromamba/bin/latexocr", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/home/rafael/micromamba/lib/python3.12/site-packages/pix2tex/__main__.py", line 25, in main
    from .gui import main
  File "/home/rafael/micromamba/lib/python3.12/site-packages/pix2tex/gui.py", line 18, in <module>
    from pix2tex import cli
  File "/home/rafael/micromamba/lib/python3.12/site-packages/pix2tex/cli.py", line 1, in <module>
    from pix2tex.dataset.transforms import test_transform
  File "/home/rafael/micromamba/lib/python3.12/site-packages/pix2tex/dataset/transforms.py", line 1, in <module>
    import albumentations as alb
  File "/home/rafael/micromamba/lib/python3.12/site-packages/albumentations/__init__.py", line 3, in <module>
    from .augmentations import *
  File "/home/rafael/micromamba/lib/python3.12/site-packages/albumentations/augmentations/__init__.py", line 1, in <module>
    from .blur.functional import *
  File "/home/rafael/micromamba/lib/python3.12/site-packages/albumentations/augmentations/blur/__init__.py", line 1, in <module>
    from .functional import *
  File "/home/rafael/micromamba/lib/python3.12/site-packages/albumentations/augmentations/blur/functional.py", line 5, in <module>
    import cv2
  File "/home/rafael/micromamba/lib/python3.12/site-packages/cv2/__init__.py", line 181, in <module>
    bootstrap()
  File "/home/rafael/micromamba/lib/python3.12/site-packages/cv2/__init__.py", line 153, in bootstrap
    native_module = importlib.import_module("cv2")
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/rafael/micromamba/lib/python3.12/importlib/__init__.py", line 90, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ImportError: numpy.core.multiarray failed to import

later I might try to implement the suggested changes of imposing a numpy version.