nilomr / pykanto

A python library for animal vocalisation analysis
https://nilomr.github.io/pykanto
MIT License
30 stars 3 forks source link

Issue Installing pykanto with Jupyter Notebook on macOS - Dependency Conflicts with attrs and jsonschema #40

Open advaymishra2003 opened 3 days ago

advaymishra2003 commented 3 days ago

@nilomr

I'm trying to set up the pykanto library in a Conda environment on macOS for bioacoustic data analysis, but I've encountered persistent issues with dependencies, specifically involving attrs, jsonschema, and jupyter_events. I’d appreciate any help troubleshooting or resolving these conflicts.

System Details: OS: macOS (ARM architecture) Python Version: 3.9 (installed via Anaconda) Conda Environment: Created specifically for pykanto Problem Description: I initially installed pykanto using Conda and pip, but I encountered errors when trying to open Jupyter Notebook in the environment. The main issue seems to be conflicting dependencies among attrs, jsonschema, and jupyter_events, which are required by jupyter and pykanto.

Steps I Took: Created a new Conda environment with Python 3.9 and installed Jupyter Notebook.

Followed the macOS-specific installation guide for pykanto:

Installed dependencies like libsndfile and grpcio. Installed pykanto via pip. When trying to launch Jupyter Notebook in this environment, I encountered the following error:

ModuleNotFoundError: No module named 'attrs' I attempted to resolve this by upgrading attrs to version 24.2.0, which leads to further issues:

ERROR: "pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts. audio-metadata 0.11.1 requires attrs<19.4,>=18.2, but you have attrs 24.2.0 which is incompatible." Specific Error Message: When attempting to run Jupyter Notebook, I get this traceback:

Traceback (most recent call last): File "/opt/anaconda3/envs/pykanto_env/bin/jupyter-notebook", line 7, in from notebook.app import main File "/opt/anaconda3/envs/pykanto_env/lib/python3.9/site-packages/notebook/app.py", line 17, in from jupyter_server.serverapp import flags File "/opt/anaconda3/envs/pykanto_env/lib/python3.9/site-packages/jupyter_server/serverapp.py", line 39, in from jupyter_events.logger import EventLogger File "/opt/anaconda3/envs/pykanto_env/lib/python3.9/site-packages/jupyter_events/init.py", line 3, in from .logger import EVENTS_METADATA_VERSION, EventLogger File "/opt/anaconda3/envs/pykanto_env/lib/python3.9/site-packages/jupyter_events/logger.py", line 19, in from .schema import SchemaType File "/opt/anaconda3/envs/pykanto_env/lib/python3.9/site-packages/jupyter_events/schema.py", line 18, in from .validators import draft7_format_checker, validate_schema File "/opt/anaconda3/envs/pykanto_env/lib/python3.9/site-packages/jupyter_events/validators.py", line 44, in JUPYTER_EVENTS_SCHEMA_VALIDATOR = Draft7Validator( TypeError: init() got an unexpected keyword argument 'registry'

pykanto requires specific versions of attrs and jsonschema that conflict with the requirements for jupyter_events, which is essential for Jupyter Notebook. Dependencies like audio-metadata and tbm-utils in pykanto cause compatibility issues when attempting to use updated versions of attrs and jsonschema. Questions: Has anyone successfully installed pykanto with Jupyter on macOS without these dependency conflicts? Are there compatible versions of attrs, jsonschema, and jupyter_events that work together with pykanto? Should I separate pykanto and Jupyter into different environments?

nilomr commented 1 day ago

Hi @advaymishra2003!

Thanks for pointing this out. Since Jupyter isn’t a dependency of pykanto and I don’t use it, this issue hadn’t come up before. However, as you’ve noted, some dependency conflicts arise due to newer versions of libraries Jupyter relies on.

I've added a patch with optional dependencies for Jupyter that should resolve these conflicts. You can try installing pykanto with Jupyter support as follows:

conda create -n <env_name> python=3.9 -y
conda activate <env_name>
pip install pykanto'[jupyter]'

Let me know if this helps or if you encounter other issues!