joeweiss / birdnetlib

A python api for BirdNET-Lite and BirdNET-Analyzer
https://joeweiss.github.io/birdnetlib/
Apache License 2.0
41 stars 14 forks source link

ModuleError: **tensorflow.python.distribute.load_context** #102

Closed aologan closed 8 months ago

aologan commented 10 months ago

After installing birdnetlib with tensor flow, librosa and all other needed dependencies. I've run into an error I've attached below. This is happening when I'm trying to import birdnetlib into my python file. I'm using tensorflow version 2.15.0. Does anyone know a work around for this. Am I using the wrong version? When I look at the tf documentation I cant even find a module called distribute.load_context :

ModuleNotFoundError: No module named tensorflow.python.distribute.load_context

joeweiss commented 10 months ago

Hi @aologan

I haven't seen that before. I just reran the test runner which used the latest tensorflow version from pip, 2.15.0.post1. It passed on all supported Python versions (3.9, 3.10, 3.11).

I would check that Python is actually loading the version of tensorflow that you installed. In Python, run the following code to print out the version number:

import tensorflow as tf
print(tf.__version__)

Assuming that is correct, are you able to run the analyzer.py script from the BirdNET-Analyzer project? The projects have the same tensorflow dependencies.

aologan commented 10 months ago

Unfortunatly I run into the same error. Here is the full output from terminal:

2023-12-13 09:46:25.218613: I tensorflow/core/util/port.cc:113] oneDNN custom operations are on. You may see slightly different numerical results due to floating-point round-off errors from different computation orders. To turn them off, set the environment variable TF_ENABLE_ONEDNN_OPTS=0. Traceback (most recent call last): File "", line 1, in File "C:\Users\talogan\AppData\Roaming\Python\Python39\site-packages\tensorflow__init.py", line 47, in from tensorflow._api.v2 import internal File "C:\Users\talogan\AppData\Roaming\Python\Python39\site-packages\tensorflow_api\v2\internal\init__.py", line 27, in from tensorflow.python.distribute.load_context import load_context # line: 49 ModuleNotFoundError: No module named 'tensorflow.python.distribute.load_context'

joeweiss commented 10 months ago

If import tensorflow as tf raises ModuleNotFoundError, then I don't think I can help much.

My only suggestion would be uninstall and reinstall tensorflow.

python -m pip uninstall tensorflow
python -m pip install tensorflow

Beyond that, I think you'll have to reach out to another forum for troubleshooting a tensorflow install issue. tensorflow install issues are outside my expertise.