Unable to Install Pyviz

Have a Flask app that was working just fine prior to updating my Mac to Sonoma. Now unable to install pyviz. All other packages are installing correctly. Have tried downgrading Python from 3.12 to an earlier release but haven’t found success. Desperate for help. Thanks!

(.venv) macbook-pro-2:spotifywebapp Chris$ pip install pyviz
Collecting pyviz
  Using cached pyviz-0.10.3-py2.py3-none-any.whl (16.4 MB)
Collecting bokeh>=1.2.0 (from pyviz)
  Using cached bokeh-3.3.3-py3-none-any.whl.metadata (12 kB)
Collecting holoviews>=1.12.3 (from pyviz)
  Using cached holoviews-1.18.1-py2.py3-none-any.whl.metadata (20 kB)
Collecting hvplot>=0.4.0 (from pyviz)
  Using cached hvplot-0.9.1-py2.py3-none-any.whl.metadata (20 kB)
Collecting datashader>=0.7.0 (from pyviz)
  Using cached datashader-0.16.0-py2.py3-none-any.whl.metadata (11 kB)
Collecting panel>=0.6.0 (from pyviz)
  Using cached panel-1.3.6-py2.py3-none-any.whl.metadata (24 kB)
Collecting param>=1.9.1 (from pyviz)
  Using cached param-2.0.1-py3-none-any.whl.metadata (5.9 kB)
Collecting pyct>=0.4.6 (from pyct[cmd]>=0.4.6->pyviz)
  Using cached pyct-0.5.0-py2.py3-none-any.whl (15 kB)
Collecting ipython<=7.1.1,>=5.4.0 (from pyviz)
  Using cached ipython-7.1.1-py3-none-any.whl (764 kB)
Requirement already satisfied: numpy>=1.16.4 in ./.venv/lib/python3.12/site-packages (from pyviz) (1.26.3)
Collecting rise (from pyviz)
  Using cached rise-5.7.1-py2.py3-none-any.whl (4.3 MB)
Collecting dask>=0.18.2 (from dask[complete]>=0.18.2->pyviz)
  Using cached dask-2024.1.0-py3-none-any.whl.metadata (3.7 kB)
Collecting notebook>=5.5 (from pyviz)
  Using cached notebook-7.0.6-py3-none-any.whl.metadata (10 kB)
Collecting matplotlib==3.0.3 (from pyviz)
  Using cached matplotlib-3.0.3.tar.gz (36.6 MB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... error
  error: subprocess-exited-with-error
  
  × Getting requirements to build wheel did not run successfully.
  │ exit code: 1
  ╰─> [29 lines of output]
      Traceback (most recent call last):
        File "/Users/Chris/Desktop/spotifywebapp/.venv/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
          main()
        File "/Users/Chris/Desktop/spotifywebapp/.venv/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/Users/Chris/Desktop/spotifywebapp/.venv/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 118, in get_requires_for_build_wheel
          return hook(config_settings)
                 ^^^^^^^^^^^^^^^^^^^^^
        File "/private/var/folders/c_/m3248b653bnb515zr8fdy6zc0000gn/T/pip-build-env-wvot59ba/overlay/lib/python3.12/site-packages/setuptools/build_meta.py", line 325, in get_requires_for_build_wheel
          return self._get_build_requires(config_settings, requirements=['wheel'])
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/private/var/folders/c_/m3248b653bnb515zr8fdy6zc0000gn/T/pip-build-env-wvot59ba/overlay/lib/python3.12/site-packages/setuptools/build_meta.py", line 295, in _get_build_requires
          self.run_setup()
        File "/private/var/folders/c_/m3248b653bnb515zr8fdy6zc0000gn/T/pip-build-env-wvot59ba/overlay/lib/python3.12/site-packages/setuptools/build_meta.py", line 480, in run_setup
          super(_BuildMetaLegacyBackend, self).run_setup(setup_script=setup_script)
        File "/private/var/folders/c_/m3248b653bnb515zr8fdy6zc0000gn/T/pip-build-env-wvot59ba/overlay/lib/python3.12/site-packages/setuptools/build_meta.py", line 311, in run_setup
          exec(code, locals())
        File "<string>", line 53, in <module>
        File "/private/var/folders/c_/m3248b653bnb515zr8fdy6zc0000gn/T/pip-install-_aln1klx/matplotlib_26f7188e52274b2dae3811fd69e3090f/versioneer.py", line 1410, in get_version
          return get_versions()["version"]
                 ^^^^^^^^^^^^^^
        File "/private/var/folders/c_/m3248b653bnb515zr8fdy6zc0000gn/T/pip-install-_aln1klx/matplotlib_26f7188e52274b2dae3811fd69e3090f/versioneer.py", line 1344, in get_versions
          cfg = get_config_from_root(root)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/private/var/folders/c_/m3248b653bnb515zr8fdy6zc0000gn/T/pip-install-_aln1klx/matplotlib_26f7188e52274b2dae3811fd69e3090f/versioneer.py", line 401, in get_config_from_root
          parser = configparser.SafeConfigParser()
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      AttributeError: module 'configparser' has no attribute 'SafeConfigParser'. Did you mean: 'RawConfigParser'?
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.

Hey there have you tried upgrade of matplotlib first before installing pyviz

In Python 3.2, the base ConfigParser class in the standard library configparser module was replaced with the SafeConfigParser implementation, so that this would be the default parser, and SafeConfigParser was made into a deprecated alias. For example, from the Python 3.8 standard library source code:

class SafeConfigParser(ConfigParser):
    """ConfigParser alias for backwards compatibility purposes."""

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        warnings.warn(
            "The SafeConfigParser class has been renamed to ConfigParser "
            "in Python 3.2. This alias will be removed in future versions."
            " Use ConfigParser directly instead.",
            DeprecationWarning, stacklevel=2
        )

Even in prehistoric times, the advice was to use SafeConfigParser by default:

So, older projects (the public release history of Matplotlib goes back to 2004, to say nothing of unreleased development versions) made that choice, and didn’t update unless and until really forced.

Now they have been forced, because the alias has been removed in 3.12, after a stronger warning in 3.11.

In this case, the call is being made by the build system (which is also written in Python). The version of pyviz that Pip selected for you believes that it can be installed on Python 3.12; and it expects a particular version of matplotlib; but that version of matplotlib can’t be built on 3.12 with your current setup. Since you have a “sdist” (source distribution) for matplotlib already stored locally, Pip tries to use that instead of looking for a Matplotlib wheel on PyPI.

3.0.3 is a fairly old version of Matplotlib - it was released way back in 2019. When it was released, it simply claimed to support Python versions 3.5 and greater - the ones currently available. As to whether the built Matplotlib wheel will actually work on 3.12 (assuming there is one for your platform!), there is no easy way to know - when they produced the wheels, 3.12 didn’t exist, so they couldn’t possibly have tested that; and they aren’t going to test it now, because they’re busy working on (checks notes) the 3.8 branch.

You can try removing the cached matplotlib-3.0.3.tar.gz (I don’t know offhand how to find the cache) and then pip install matplotlib==3.0.3 directly. If you’re lucky, there’s a wheel for your platform, and you somehow got the .tar.gz file by mistake. But most likely it just isn’t going to work (you probably have this sdist you’ve tried the installation multiple times, and Pip couldn’t find a wheel the first time).

In which case:

You probably have the right idea here.

To diagnose the new problem, we would need to know exactly what version you tried using, and see exactly what happened when you tried.

One thing to consider: the latest version of Pyviz was also released in 2019. At that time, the specified “pinned” version of Matplotlib was only a few months old. This release is documented as requiring Python 3.6 or later; and 3.8 had not been released quite yet.

So I would try to find either Python 3.6 or 3.7 to be sure, if you have to use this code. But keep in mind that 3.7 is now EOL. You might be better served by trying to find a different library that does what Pyviz is supposed to do.

Some additional, somewhat ironic notes.

The Matplotlib build is failing because Matplotlib versions this old used their own script called versioneer.py to… avoid needing to update the version number in the main build script manually (instead reading and parsing that information when Pip tries to build a wheel from the sdist). That in turn exists as a separate package; but Matplotlib made their own vendored copy of it so that they could generate a setup.cfg for each version’s sdist from a common template file, as part of their sdist building process (yes, you can have one of those, separate from wheel building). That modified version is based on versioneer 0.15, which was released mid-2015.

Contemporary versions of versioneer do use the ConfigParser name as expected; I can’t find older versions to check when this was fixed. They also completely reorganize the project so that it isn’t a monolithic single-file script.

On the other hand, even the latest version available at the time of the Matplotlib 3.0.3 release (versioneer 0.18, released Jan 1, 2017) was only documented as supporting Python up to 3.5. Which is fairly reasonable, considering that 3.6 had just come out barely a week before that.