Skip to content

Issue with numpy v1 and seaborn in colab #108

@MitchellAcoustics

Description

@MitchellAcoustics

In a new google colab doc, with v0.7.8 of soundscapy installed, we get the following numpy error on import:

TypeError                                 Traceback (most recent call last)
[<ipython-input-5-eaebbc27c797>](https://naehqa8ncgp-496ff2e9c6d22116-0-colab.googleusercontent.com/outputframe.html?vrz=colab_20250227-060209_RC00_731674681#) in <cell line: 0>()
----> 1 import soundscapy as sspy
      2 import seaborn as sns
      3 import plot_likert
      4 import pandas as pd
      5 

12 frames
[/usr/local/lib/python3.11/dist-packages/soundscapy/__init__.py](https://naehqa8ncgp-496ff2e9c6d22116-0-colab.googleusercontent.com/outputframe.html?vrz=colab_20250227-060209_RC00_731674681#) in <module>
     19 from soundscapy import surveys
     20 from soundscapy import databases
---> 21 from soundscapy import plotting
     22 from soundscapy.logging import setup_logging
     23 from soundscapy.databases import araus, isd, satp

[/usr/local/lib/python3.11/dist-packages/soundscapy/plotting/__init__.py](https://naehqa8ncgp-496ff2e9c6d22116-0-colab.googleusercontent.com/outputframe.html?vrz=colab_20250227-060209_RC00_731674681#) in <module>
     24 
     25 from . import likert
---> 26 from .circumplex_plot import CircumplexPlot, CircumplexPlotParams
     27 from .plot_functions import create_circumplex_subplots, density_plot, scatter_plot
     28 from .plotting_utils import Backend, PlotType

[/usr/local/lib/python3.11/dist-packages/soundscapy/plotting/circumplex_plot.py](https://naehqa8ncgp-496ff2e9c6d22116-0-colab.googleusercontent.com/outputframe.html?vrz=colab_20250227-060209_RC00_731674681#) in <module>
     10 import pandas as pd
     11 
---> 12 from soundscapy.plotting.backends import PlotlyBackend, SeabornBackend
     13 from soundscapy.plotting.plotting_utils import (
     14     Backend,

[/usr/local/lib/python3.11/dist-packages/soundscapy/plotting/backends.py](https://naehqa8ncgp-496ff2e9c6d22116-0-colab.googleusercontent.com/outputframe.html?vrz=colab_20250227-060209_RC00_731674681#) in <module>
      5 import plotly.express as px
      6 import plotly.graph_objects as go
----> 7 import seaborn as sns
      8 
      9 from soundscapy.plotting.stylers import SeabornStyler, StyleOptions

[/usr/local/lib/python3.11/dist-packages/seaborn/__init__.py](https://naehqa8ncgp-496ff2e9c6d22116-0-colab.googleusercontent.com/outputframe.html?vrz=colab_20250227-060209_RC00_731674681#) in <module>
      3 from .utils import *  # noqa: F401,F403
      4 from .palettes import *  # noqa: F401,F403
----> 5 from .relational import *  # noqa: F401,F403
      6 from .regression import *  # noqa: F401,F403
      7 from .categorical import *  # noqa: F401,F403

[/usr/local/lib/python3.11/dist-packages/seaborn/relational.py](https://naehqa8ncgp-496ff2e9c6d22116-0-colab.googleusercontent.com/outputframe.html?vrz=colab_20250227-060209_RC00_731674681#) in <module>
     19 )
     20 from ._compat import groupby_apply_include_groups
---> 21 from ._statistics import EstimateAggregator, WeightedAggregator
     22 from .axisgrid import FacetGrid, _facet_docs
     23 from ._docstrings import DocstringComponents, _core_docs

[/usr/local/lib/python3.11/dist-packages/seaborn/_statistics.py](https://naehqa8ncgp-496ff2e9c6d22116-0-colab.googleusercontent.com/outputframe.html?vrz=colab_20250227-060209_RC00_731674681#) in <module>
     30 import pandas as pd
     31 try:
---> 32     from scipy.stats import gaussian_kde
     33     _no_scipy = False
     34 except ImportError:

[/usr/local/lib/python3.11/dist-packages/scipy/stats/__init__.py](https://naehqa8ncgp-496ff2e9c6d22116-0-colab.googleusercontent.com/outputframe.html?vrz=colab_20250227-060209_RC00_731674681#) in <module>
    650     make_distribution, Mixture, order_statistic, truncate, exp, log, abs
    651 )
--> 652 from ._new_distributions import Normal, Uniform
    653 from ._mgc import multiscale_graphcorr
    654 from ._correlation import chatterjeexi

[/usr/local/lib/python3.11/dist-packages/scipy/stats/_new_distributions.py](https://naehqa8ncgp-496ff2e9c6d22116-0-colab.googleusercontent.com/outputframe.html?vrz=colab_20250227-060209_RC00_731674681#) in <module>
    373 _module = sys.modules[__name__].__dict__
    374 for dist_name in __all__:
--> 375     _module[dist_name].__doc__ = _combine_docs(_module[dist_name])

[/usr/local/lib/python3.11/dist-packages/scipy/stats/_distribution_infrastructure.py](https://naehqa8ncgp-496ff2e9c6d22116-0-colab.googleusercontent.com/outputframe.html?vrz=colab_20250227-060209_RC00_731674681#) in _combine_docs(dist_family, include_examples)
   1270             doc[field].append(_generate_domain_support(dist_family))
   1271         elif field == 'Examples':
-> 1272             doc[field] = [_generate_example(dist_family)]
   1273         else:
   1274             doc[field] += superdoc[field]

[/usr/local/lib/python3.11/dist-packages/scipy/stats/_distribution_infrastructure.py](https://naehqa8ncgp-496ff2e9c6d22116-0-colab.googleusercontent.com/outputframe.html?vrz=colab_20250227-060209_RC00_731674681#) in _generate_example(dist_family)
   1412 
   1413     >>> X.sample(shape=(4,))
-> 1414     {repr(X.sample(shape=(4,)))}  # may vary
   1415     """
   1416     # remove the indentation due to use of block quote within function;

[/usr/local/lib/python3.11/dist-packages/numpy/core/arrayprint.py](https://naehqa8ncgp-496ff2e9c6d22116-0-colab.googleusercontent.com/outputframe.html?vrz=colab_20250227-060209_RC00_731674681#) in _array_repr_implementation(arr, max_line_width, precision, suppress_small, array2string)
   1497         class_name = "array"
   1498 
-> 1499     skipdtype = dtype_is_implied(arr.dtype) and arr.size > 0
   1500 
   1501     prefix = class_name + "("

[/usr/local/lib/python3.11/dist-packages/numpy/core/arrayprint.py](https://naehqa8ncgp-496ff2e9c6d22116-0-colab.googleusercontent.com/outputframe.html?vrz=colab_20250227-060209_RC00_731674681#) in dtype_is_implied(dtype)
   1439     """
   1440     dtype = np.dtype(dtype)
-> 1441     if _format_options['legacy'] <= 113 and dtype.type == bool_:
   1442         return False
   1443 

TypeError: '<=' not supported between instances of 'str' and 'int'

This is resolved by updating numpy in colab !pip install --upgrade numpy:

  Attempting uninstall: numpy
    Found existing installation: numpy 1.26.4
    Uninstalling numpy-1.26.4:
      Successfully uninstalled numpy-1.26.4
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.
gensim 4.3.3 requires numpy<2.0,>=1.18.5, but you have numpy 2.2.3 which is incompatible.
gensim 4.3.3 requires scipy<1.14.0,>=1.7.0, but you have scipy 1.15.2 which is incompatible.
langchain 0.3.19 requires numpy<2,>=1.26.4; python_version < "3.12", but you have numpy 2.2.3 which is incompatible.
tensorflow 2.18.0 requires numpy<2.1.0,>=1.26.0, but you have numpy 2.2.3 which is incompatible.
thinc 8.2.5 requires numpy<2.0.0,>=1.19.0; python_version >= "3.9", but you have numpy 2.2.3 which is incompatible.
pytensor 2.27.1 requires numpy<2,>=1.17.0, but you have numpy 2.2.3 which is incompatible.
numba 0.61.0 requires numpy<2.2,>=1.24, but you have numpy 2.2.3 which is incompatible.
Successfully installed numpy-2.2.3

However, clearly something is still wrong with our compatibility with numpy v1.

Metadata

Metadata

Labels

bugSomething isn't workingdependenciesIssues with dependencies or installation

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions