CPJKU / partitura

A python package for handling modern staff notation of music
https://partitura.readthedocs.io
Apache License 2.0
238 stars 18 forks source link

Import bug due to mido dependency #388

Open BaptisteHi opened 1 week ago

BaptisteHi commented 1 week ago

Hi,

I have encountered issues while using google collab tutorials for partitura : While importing partitura, there is a conflict issue raised because of the mido dependency which requires packaging with the version 23.1 while newer versions are available.

I have tried downgrading packaging's version right before the import and right before the installation of partitura using pip but it didn't work out.

Here is the message error :

Requirement already satisfied: packaging==23.1 in /usr/local/lib/python3.10/dist-packages (23.1)

---------------------------------------------------------------------------

ContextualVersionConflict                 Traceback (most recent call last)

[<ipython-input-7-fb54198d7d05>](https://localhost:8080/#) in <cell line: 4>()
      2 import os
      3 get_ipython().system('pip install packaging==23.1')
----> 4 import partitura as pt
      5 import numpy as np
      6 import matplotlib.pyplot as plt

5 frames

[/usr/local/lib/python3.10/dist-packages/pkg_resources/__init__.py](https://localhost:8080/#) in _resolve_dist(self, req, best, replace_conflicting, env, installer, required_by, to_activate)
    937             # Oops, the "best" so far conflicts with a dependency
    938             dependent_req = required_by[req]
--> 939             raise VersionConflict(dist, req).with_context(dependent_req)
    940         return dist
    941 

ContextualVersionConflict: (packaging 24.1 (/usr/local/lib/python3.10/dist-packages), Requirement.parse('packaging~=23.1'), {'mido'})
manoskary commented 1 week ago

Hello and thanks for raising this issue. It looks that the Google colab's cache is not updated and although packaging 24.1 is no longer there and packaging 23.1 took its place somehow it still exists in the site_packages folder. It is a weird error, but it seems to be related mostly with Colab and not with the partitura installation, I will dig a bit deeper and then try to find a better solution.

If you still want to run tutorial, run the first shells that install partitura and then refresh the runtime, and run through the notebook again. This should fix the error.

CarlosCancino-Chacon commented 2 hours ago

Hi @BaptisteHi and @manoskary! I found a potential solution that we can use for the time being. We can use an older version of mido to avoid the issues with packaging.

I will create a pull request in the tutorial repository to address these issue

# Issues on Colab with newer versions of MIDO
! pip install mido==1.2.10