Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NumPy conflict for Analyzer() #115

Open
herbbetz opened this issue Jun 29, 2024 · 3 comments
Open

NumPy conflict for Analyzer() #115

herbbetz opened this issue Jun 29, 2024 · 3 comments

Comments

@herbbetz
Copy link

Dear Mr. Weiss,
I just tried your code from 6.2 of https://github.com/kahst/BirdNET-Analyzer.
My system is bookworm 64bit on RPi4B. I installed all the libraries into a venv and started your example.py from there.
It says:

A module that was compiled using NumPy 1.x cannot be run in
NumPy 2.0.0 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.

Traceback (most recent call last):  File "/home/pi/audiostation/birdnet.py", line 7, in <module>
    analyzer = Analyzer()
  File "/home/pi/herbvenv/lib/python3.11/site-packages/birdnetlib/analyzer.py", line 122, in __init__
    self.load_model()
  File "/home/pi/herbvenv/lib/python3.11/site-packages/birdnetlib/analyzer.py", line 386, in load_model
    self.interpreter = tflite.Interpreter(
  File "/home/pi/herbvenv/lib/python3.11/site-packages/tflite_runtime/interpreter.py", line 464, in __init__
    self._interpreter = _interpreter_wrapper.CreateWrapperFromFile(
AttributeError: _ARRAY_API not found
ImportError: numpy.core.multiarray failed to import

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/pi/audiostation/birdnet.py", line 7, in <module>
    analyzer = Analyzer()
               ^^^^^^^^^^
  File "/home/pi/herbvenv/lib/python3.11/site-packages/birdnetlib/analyzer.py", line 122, in __init__
    self.load_model()
  File "/home/pi/herbvenv/lib/python3.11/site-packages/birdnetlib/analyzer.py", line 386, in load_model
    self.interpreter = tflite.Interpreter(
                       ^^^^^^^^^^^^^^^^^^^
  File "/home/pi/herbvenv/lib/python3.11/site-packages/tflite_runtime/interpreter.py", line 464, in __init__
    self._interpreter = _interpreter_wrapper.CreateWrapperFromFile(
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
SystemError: <built-in method CreateWrapperFromFile of PyCapsule object at 0x7f6f7a95c0> returned a result with an exception set

What should I do? Thanks for any hints, H.Betz (Germany)

@MichaelPWalter
Copy link

Same issue today. Running on RPi 5 using Bookworm 64-bit. I believe the issue lies with NumPy 2.0. I will try to downgrade my version of NumPy to 1.26.4 once ive figured out how to do that.
Viele Gruesse, Michael

@joeweiss
Copy link
Owner

joeweiss commented Jul 4, 2024

Thanks for the reports @herbbetz and @MichaelPWalter. I'll take a look in the next few days and see what needs to change for NumPy 2.

Installing birdnetlib itself doesn't directly install numpy, but it is expected as a dependency from BirdNET-Analyzer. I'll have to investigate.

To downgrade (if using pip), this should work:

pip uninstall numpy -y
pip install numpy==1.26.4

@MichaelPWalter
Copy link

I have tried connecting to RPi with ssh and running sudo apt install python3-numpy but this had no effect. I will reinstall BirdNet pi from a different fork that advertises RPi5 compatibility curl -s https://raw.githubusercontent.com/Nachtzuster/BirdNET-Pi/main/newinstaller.sh | bash
Just tested and confirm works !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants