epistoteles / TensorHue

TensorHue is a Python library that allows you to visualize tensors right in your console, making understanding and debugging tensor contents easier.
73 stars 1 forks source link

Can't import - no module named 'tensorhue.connectors' #7

Closed Datamance closed 1 month ago

Datamance commented 1 month ago

Here's what I see when I try to import in an IPython session:

----> 1 import tensorhue

File ~/GradSchool/VHLab/rftk/env/lib/python3.11/site-packages/tensorhue/__init__.py:5
      3 from tensorhue.colors import COLORS, ColorScheme
      4 from tensorhue._print_opts import PRINT_OPTS, set_printoptions
----> 5 from tensorhue.connectors._numpy import NumpyArrayWrapper
      6 from tensorhue.connectors._torch import _tensorhue_to_numpy_torch
      7 from tensorhue.connectors._jax import _tensorhue_to_numpy_jax

ModuleNotFoundError: No module named 'tensorhue.connectors'

Don't you need an __init__.py file in the connectors directory for Python's module system to recognize it? I haven't tried to make a package in a while but I vaguely recall needing to do that.

SvenLorenzTransfermedia commented 1 month ago

Fyi 0.0.11 works for torch, but getting the same error for 0.0.13.

epistoteles commented 1 month ago

Hello @Datamance and @SvenLorenzTransfermedia, and thank you for giving TensorHue a try, creating and contributing to this issue, and proposing a solution!

The issue you described should now be fixed in TensorHue 0.0.15. The affected versions after 0.0.11 have been yanked from PyPi.

Part of the problem was indeed the missing __init__.py file. My assumption was that this could be omitted due to the implicit namespace packages introduced in PEP 420, but it seems that this understanding was either wrong or not applicable when building with setuptools. My setup.cfg tries to autodetect packages with

[options]
packages = find:

[options.packages.find]
include = tensorhue

which I also had to change to

[options]
packages = find:

[options.packages.find]
include = tensorhue*

to include the newly introduced connectors. The problem never occurred when installing the package locally in editable mode (pip install -e .), which I used for testing.

Feel free to reopen this issue in case this problem persists with v0.0.15, or open a new one if you'd like to see any features implemented in TensorHue!