CharlesPDX / fuzzy-artmap

1 stars 1 forks source link

No module named 'numpy' #3

Closed kellyfj closed 1 month ago

kellyfj commented 3 months ago

Great code - easy to read. But I hit the following. I am a newbie at Python so maybe I missed something.

python examples/circle_square_test.py
/Users/kellyfj/miniconda3/lib/python3.11/site-packages/torch/nn/modules/transformer.py:20: UserWarning: Failed to initialize NumPy: No module named 'numpy' (Triggered internally at /Users/runner/work/pytorch/pytorch/pytorch/torch/csrc/utils/tensor_numpy.cpp:84.)
  device: torch.device = torch.device(torch._C._get_default_device()),  # torch.device('cpu'),
2024-08-11 17:38:23.454173
tensor([[1., 0.]])
tensor([[0., 1.]])
elapsed: 0:00:00.476760- 2024-08-11 17:38:23.930933
Counter({True: 917, False: 83})
torch.Size([51, 4])
torch.Size([51, 2])
tensor(18)

then if I do

pip3 install numpy
Collecting numpy
  Using cached numpy-2.0.1-cp311-cp311-macosx_10_9_x86_64.whl.metadata (60 kB)
Using cached numpy-2.0.1-cp311-cp311-macosx_10_9_x86_64.whl (21.2 MB)
Installing collected packages: numpy
Successfully installed numpy-2.0.1

I get

python examples/circle_square_test.py

A module that was compiled using NumPy 1.x cannot be run in
NumPy 2.0.1 as it may crash. To support both 1.x and 2.x
versions of NumPy, modules must be compiled with NumPy 2.0.
Some module may need to rebuild instead e.g. with 'pybind11>=2.12'.

If you are a user of the module, the easiest solution will be to
downgrade to 'numpy<2' or try to upgrade the affected module.
We expect that some modules will need time to support NumPy 2.
kellyfj commented 3 months ago

Also FYI

python examples/procedural_circle_square_test.py
Traceback (most recent call last):
  File "/Users/kellyfj/dev/fuzzy-artmap/examples/procedural_circle_square_test.py", line 12, in <module>
    import tornado
ModuleNotFoundError: No module named 'tornado'

and then after

pip3 install "tornado"

I get

python examples/procedural_circle_square_test.py
Traceback (most recent call last):
  File "/Users/kellyfj/dev/fuzzy-artmap/examples/procedural_circle_square_test.py", line 14, in <module>
    from fuzzy_artmap.procedural_fuzzy_artmap import FuzzyArtMap
ModuleNotFoundError: No module named 'fuzzy_artmap'
CharlesPDX commented 3 months ago

Thanks for raising these issues!

For the numpy issue, that actually looks like it's caused by the version of pytorch you're using. You could try upgrading your version of pytorch (e.g. pip install torch -U) or uninstall numpy 2 (pip uninstall numpy) and then install a 1.x version (pip install "numpy<2"). Either approach might work, and while it doesn't actually appear to be impacting the code's ability to run, I'm not sure what else you might run into.

For the tornado and ModuleNotFoundError, those should be fixed. The tornado dependency was some vestigial code that's now removed, and the hack to put the parent path in has also been correct, so procedural_circle_square_test.py should run correctly now.

CharlesPDX commented 2 months ago

HI @kellyfj ,

If you're still having issues please feel free to update this issue, otherwise I'll be closing it in a week or so!

Thanks,

-Charles