Skip to content

Instantly share code, notes, and snippets.

@bingo-tango
Last active May 16, 2024 13:42
Show Gist options
  • Save bingo-tango/1c8104036f1fd79c3e14d4c1962dbfbf to your computer and use it in GitHub Desktop.
Save bingo-tango/1c8104036f1fd79c3e14d4c1962dbfbf to your computer and use it in GitHub Desktop.
Running BirdNET Alayzer GUI on MacOS with Apple M1, M2, etc.

Guide to running the BirdNET Analyzer GUI on Mac computers with Apple silicon

Requirements

  1. Python 3.10 (3.11 might work, have not tested. 3.9 does not work.)
    • The easiest way to install this is using Homebrew. If you do not have Homebrew installed, you will need to install that.
  2. The BirdNET Analyzer repository.

Check Python versions installed

You need to determine which version(s) of python you have installed. Open a terminal, and try these commands:

python --version

python3 --version

python3.10 --version

If any of them return 'Python 3.10.14', then use that command to create your virtual environment.

If none of them do (you get 'command not found') then you need to install Python 3.10.

To Install Python 3.10

My preferred method is using Homebrew https://brew.sh/.

Check if you have Homebrew installed

Open a terminal and run

brew --version

If you get 'command not found' you need to install Homebrew. If not, skip to Install Python

Install Homebrew

You will need administrator privledges to run this. If your IT department requires you to do something to get Admin access, do that first.

Open a terminal and run

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

If you are asked for a password enter the password you use to log in to your computer.

Install Python

In the terminal, run

brew install python@3.10

Install Git

If you want to clone the repository from GitHub, install Git:

brew install git

Clone BirdNET Analyzer repository

In the terminal, navigate to where you want the folder (cd ~/Documents) and run:

git clone https://github.com/kahst/BirdNET-Analyzer.git

Or download a zip from https://github.com/kahst/BirdNET-Analyzer and unzip it.

Now navigate to that folder in the terminal. E.g., cd ~/Documents/BirdNET-Analyzer, or wherever you put it.

Install BirdNET Dependencies

We need to create a virtual environment and add dependencies to it.

Setup Virtual Environment

In this step, if python3.10 is not the command to run Python 3.10, replace it with the appropriate command for your computer.

Create the environment:

python3.10 -m venv venv-birdnet

Activate environment

Now we need to activate the environment we just created.

source venv-birdnet/bin/activate

After doing this, you should see (venv-birdnet) before your command prompt.

user@MyMac BirdNET-Analyzer % source venv-birdnet/bin/activate
(venv-birdnet) user@MyMac BirdNET-Analyzer % 

All of the following commands should be entered while in the virtual environment.

If you close the terminal window, you will need to re-activate the virtual environment by navigating back to this folder, cd ~/Documents/BirdNET-Analyzer and then source venv-birdnet/bin/activate.

Install pip

Since we are in the virtual environment and it was created using Python 3.10, we just need to use python instead of python3.10 for the command.

python -m pip install -U pip

Install dependencies

These can be done all at once, or one at a time.

python -m pip install tensorflow tensorflow-metal librosa resampy

-or-

python -m pip install tensorflow 
python -m pip install tensorflow-metal
python -m pip install librosa
python -m pip install resampy

TODO: ... not sure if we need tflite-runtime, ffmpeg? ...

Install pywebview and gradio to run the GUI

python -m pip install pywebview gradio

Run the Analyzer GUI

python gui.py

To Exit

To exit the virtual environment, use

deactivate

or just close the terminal window.

To Run Again

Next time you want to run the GUI, you just need to navigate to the /BirdNET-Analyzer folder and run

source venv-birdnet/bin/activate
python gui.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment