enthought / chaco

Chaco is a Python package for building interactive and custom 2-D plots.
http://docs.enthought.com/chaco/
Other
292 stars 99 forks source link

Problem with install dependencies in Python 3.8 #858

Closed timdiller closed 1 year ago

timdiller commented 1 year ago

Problem Description There is what I believe to a problem with the installation dependencies for Chaco. With a bare installation of Chaco, any attempted import results in ModuleNotFoundError: no module named 'pyparsing'. I have not tried this on platforms other than macOS, but I suspect this is not platform dependent.

Reproduction Steps:

❯ edm install -e foo chaco
No value provided for --version. Assuming 3.8
Fetching indices for runtime repositories. done
Fetching indices for package repositories. done
Fetching indices for runtime repositories. done
Installing runtime... done
The following packages will be installed:

    chaco                5.1.1-1        1022     KiB
    enable               5.3.1-5           3.3   MiB
    fonttools            4.31.1-1        985     KiB
    importlib_resources  5.4.0-1          27     KiB
    intel_openmp         2021.4.28-1       1.1   MiB
    libfreetype          2.12.1-1        637     KiB
    libharfbuzz          3.2.0-4         924     KiB
    liblcms2             2.12-1          197     KiB
    libopenjpeg          2.4.0.post1-1   190     KiB
    libpng               1.6.37-100      242     KiB
    libtiff              4.3.0-2         213     KiB
    libturbojpeg         2.1.2-1         430     KiB
    libzstd              1.5.0-1           1.12  MiB
    mkl                  2021.3.0-1      192.63  MiB
    mkl_service          2.4.0-1          47     KiB
    numpy                1.21.2-2          7.45  MiB
    pillow_simd          9.0.0.post1-2   876     KiB
    pyface               7.4.4-2           2.41  MiB
    traits               6.4.1-1           4.76  MiB
    traitsui             7.4.3-1           2.62  MiB
    zipp                 3.7.0-1           6     KiB

Do you want to continue ? [Y/n]: 
Installing/removing package(s)
chaco               [...................................................................................]

❯ edm shell -e foo
Starting new shell in EDM environment 'foo'.
Type 'exit' or 'Ctrl+D' to return.

$foo ❯ python
Enthought Deployment Manager -- https://www.enthought.com/
Python 3.8.12 |Enthought, Inc. (x86_64)| (default, Sep 27 2021, 11:51:02) 
[Clang 12.0.0 (clang-1200.0.32.29)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from chaco.api import ArrayPlotData                                                    
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/tdiller/.edm/envs/foo/lib/python3.8/site-packages/chaco/api.py", line 343, in <module>
    from chaco.overlays.api import (
  File "/Users/tdiller/.edm/envs/foo/lib/python3.8/site-packages/chaco/overlays/api.py", line 63, in <module>
    from chaco.overlays.layers.api import (
  File "/Users/tdiller/.edm/envs/foo/lib/python3.8/site-packages/chaco/overlays/layers/api.py", line 11, in <module>
    from .status_layer import ErrorLayer, StatusLayer, WarningLayer
  File "/Users/tdiller/.edm/envs/foo/lib/python3.8/site-packages/chaco/overlays/layers/status_layer.py", line 17, in <module>
    from enable.savage.svg.document import SVGDocument
  File "/Users/tdiller/.edm/envs/foo/lib/python3.8/site-packages/enable/savage/svg/document.py", line 27, in <module>
    from . import css
  File "/Users/tdiller/.edm/envs/foo/lib/python3.8/site-packages/enable/savage/svg/css/__init__.py", line 10, in <module>
    from .transform import transformList
  File "/Users/tdiller/.edm/envs/foo/lib/python3.8/site-packages/enable/savage/svg/css/transform.py", line 14, in <module>
    from pyparsing import Group, Literal, Optional, delimitedList
ModuleNotFoundError: No module named 'pyparsing'

Expected behavior: Either Chaco should include pyparsing as a dependency such that it is installed during environment creation, or maybe chaco.api could be reworked such that the pyparsing is not needed. [credit: @mdickinson for the diagnosis]

mdickinson commented 1 year ago

Thanks, @timdiller. It's worth noting that Enable is in the mix too - the dependency on pyparsing goes through Enable. However, pyparsing isn't needed for a simple import enable.api. So I see three possible resolutions:

mdickinson commented 1 year ago

@jwiggins Should pyparsing be a non-optional dependency of Enable? Or should we be fixing this entirely in Chaco-land?

jwiggins commented 1 year ago

It should probably be an optional dependency of Enable since it's only needed for the SVG bits

mdickinson commented 1 year ago

@jwiggins Thanks. Then I think the most desirable solution is probably option 3: make pyparsing an optional dependency of Chaco, and ensure (somehow) that import chaco.api doesn't automatically try to import pyparsing.

corranwebster commented 1 year ago

Slightly orthogonal, but sometimes I wonder if we should pull the svg stuff out into at least its own top-level package in enable project - almost no one knows its there and that would allow us to surface things like this more clearly.

corranwebster commented 1 year ago

This should now be resolved by #891, in particular this line: https://github.com/enthought/chaco/blob/5603512bbad193766d4d63658fa6ce2a0408045c/chaco/__init__.py#L17