NERDSITU / superblockify

Source code for superblockify
https://superblockify.city
GNU Affero General Public License v3.0
22 stars 3 forks source link

No module named 'scipy' error #86

Closed erexer closed 5 months ago

erexer commented 6 months ago

Hi, I'm a reviewer for JOSS, excited to learn more about the package! https://github.com/openjournals/joss-reviews/issues/6798

started a virtual env for python3.10.14, ran $ pip install superblockify $ python examples/00-mwe.py

it threw

$ python examples/00-mwe.py 
2024-05-31 15:37:43,244 |  WARNING | font_manager.py:1037 | Matplotlib is building the font cache; this may take a moment.
2024-05-31 15:38:00,135 |     INFO | font_manager.py:1049 | Failed to extract font properties from /System/Library/Fonts/LastResort.otf: tuple indices must be integers or slices, not str
2024-05-31 15:38:00,149 |     INFO | font_manager.py:1049 | Failed to extract font properties from /System/Library/Fonts/Supplemental/NISC18030.ttf: In FT2Font: Could not set the fontsize (invalid pixel size; error code 0x17)
2024-05-31 15:38:00,685 |     INFO | font_manager.py:1049 | Failed to extract font properties from /System/Library/Fonts/Apple Color Emoji.ttc: In FT2Font: Could not set the fontsize (invalid pixel size; error code 0x17)
2024-05-31 15:38:00,778 |     INFO | font_manager.py:1581 | generated new fontManager
Traceback (most recent call last):
  File "<mypath>/superblockify/examples/00-mwe.py", line 7, in <module>
    from superblockify import ResidentialPartitioner
  File "<mypath>/superblockify/.venv/lib/python3.10/site-packages/superblockify/__init__.py", line 7, in <module>
    from ._api import *
  File "<mypath>/superblockify/.venv/lib/python3.10/site-packages/superblockify/_api.py", line 5, in <module>
    from .partitioning import BearingPartitioner
  File "<mypath>/superblockify/.venv/lib/python3.10/site-packages/superblockify/partitioning/__init__.py", line 6, in <module>
    from .base import BasePartitioner
  File "<mypath>/superblockify/.venv/lib/python3.10/site-packages/superblockify/partitioning/base.py", line 20, in <module>
    from .checks import is_valid_partitioning
  File "<mypath>/superblockify/.venv/lib/python3.10/site-packages/superblockify/partitioning/checks.py", line 12, in <module>
    from ..utils import has_pairwise_overlap
  File "<mypath>/superblockify/.venv/lib/python3.10/site-packages/superblockify/utils.py", line 28, in <module>
    from .partitioning.utils import reduce_graph
  File "<mypath>/superblockify/.venv/lib/python3.10/site-packages/superblockify/partitioning/utils.py", line 18, in <module>
    from ..graph_stats import get_population_area, basic_graph_stats
  File "<mypath>/superblockify/.venv/lib/python3.10/site-packages/superblockify/graph_stats.py", line 7, in <module>
    from scipy.stats import entropy
ModuleNotFoundError: No module named 'scipy'

would recommend adding scipy to the list of dependencies since its used by graph_stats.py

cbueth commented 5 months ago

Hi there,

Thanks for pointing out the missing scipy dependency. We've added it to our dependencies list in bbd18576271e7f9e657dd816312a82fdafbbdaa5 and the changes are now live on the submission branch and in the PyPI package 1.0.0rc9.

Just a quick note - our package also relies on osmnx, which can't be installed with pip alone. To set up the environment correctly, please use the following command from the README.md/Installation Page:

conda create -n sb_env -c conda-forge python=3.12 osmnx=1.9.2

Other than python and osmnx it also installs scipy. But as we use it directly, it is better to include it explicitly in the package dependencies. Afterwards you can activate the environment and use pip to install superblockify. Hopefully, this should sort out the issue you've been facing. Let us know!

Thanks again for your feedback. Let us know if you have any other issues or suggestions.

erexer commented 5 months ago

Thanks for the clarification! It might be helpful to point out the osmnx installation caveat in the installation guide since others might do what I did and prefer/use a different venv setup.

cbueth commented 5 months ago

Good point! Added a note to the installation instructions, see 671f22a.

erexer commented 5 months ago

Awesome, thanks for doing that!