gempy-project / gempy

GemPy is an open-source, Python-based 3-D structural geological modeling software, which allows the implicit (i.e. automatic) creation of complex geological models from interface and orientation data. It also offers support for stochastic modeling to address parameter and model uncertainties.
https://gempy.org
European Union Public License 1.2
985 stars 234 forks source link

`pip install gempy[base]` → ModuleNotFoundError: No module named `torch` #900

Closed JoostGevaert closed 5 months ago

JoostGevaert commented 5 months ago

Hi 👋 Amazing that it's now possible to use GemPy without the need for following complicated installation instructions, and that it's now also possible to run GemPy in Google Colabs! When I want to install GemPy with the recommended installation procedure pip install gempy[base], and then try to import GemPy, I get a ModuleNotFoundError: No module named torch, see Error Message below.

To Reproduce Provide detailed steps to reproduce the behavior:

  1. Create a new conda environment with python=3.11
  2. Activate conda environment
  3. pip install gempy[base]
  4. Run Python
  5. Import gempy

Expected behavior Import without issues. This works in Google Colab, because in Google Colab Torch from PyTorch is already installed by default.

Error message

Python 3.11.9 | packaged by conda-forge | (main, Apr 19 2024, 18:27:10) [MSC v.1938 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import gempy
Setting Backend To: AvailableBackends.numpy
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\Joost.Gevaert\AppData\Local\miniforge3\envs\gempy-test\Lib\site-packages\gempy\__init__.py", line 10, in <module>
    from .core import data
  File "C:\Users\Joost.Gevaert\AppData\Local\miniforge3\envs\gempy-test\Lib\site-packages\gempy\core\data\__init__.py", line 1, in <module>
    from .geo_model import GeoModel
  File "C:\Users\Joost.Gevaert\AppData\Local\miniforge3\envs\gempy-test\Lib\site-packages\gempy\core\data\geo_model.py", line 8, in <module>
    import gempy_engine.core.data.engine_grid
  File "C:\Users\Joost.Gevaert\AppData\Local\miniforge3\envs\gempy-test\Lib\site-packages\gempy_engine\__init__.py", line 1, in <module>
    from gempy_engine.API.model.model_api import compute_model
  File "C:\Users\Joost.Gevaert\AppData\Local\miniforge3\envs\gempy-test\Lib\site-packages\gempy_engine\API\model\model_api.py", line 6, in <module>
    from ...core.data.interp_output import InterpOutput
  File "C:\Users\Joost.Gevaert\AppData\Local\miniforge3\envs\gempy-test\Lib\site-packages\gempy_engine\core\data\__init__.py", line 4, in <module>
    from .options.interpolation_options import InterpolationOptions
  File "C:\Users\Joost.Gevaert\AppData\Local\miniforge3\envs\gempy-test\Lib\site-packages\gempy_engine\core\data\options\__init__.py", line 1, in <module>
    from .interpolation_options import InterpolationOptions
  File "C:\Users\Joost.Gevaert\AppData\Local\miniforge3\envs\gempy-test\Lib\site-packages\gempy_engine\core\data\options\interpolation_options.py", line 10, in <module>
    from ..raw_arrays_solution import RawArraysSolution
  File "C:\Users\Joost.Gevaert\AppData\Local\miniforge3\envs\gempy-test\Lib\site-packages\gempy_engine\core\data\raw_arrays_solution.py", line 13, in <module>
    from ...modules.octrees_topology.octrees_topology_interface import get_regular_grid_value_for_level
  File "C:\Users\Joost.Gevaert\AppData\Local\miniforge3\envs\gempy-test\Lib\site-packages\gempy_engine\modules\octrees_topology\octrees_topology_interface.py", line 9, in <module>
    from ._octree_internals import compute_next_octree_locations
  File "C:\Users\Joost.Gevaert\AppData\Local\miniforge3\envs\gempy-test\Lib\site-packages\gempy_engine\modules\octrees_topology\_octree_internals.py", line 1, in <module>
    import torch
ModuleNotFoundError: No module named 'torch'

Desktop (please complete the following information):

Additional context Add any other context about the problem here.

flohorovicic commented 5 months ago

Dear @JoostGevaert ,

thanks a lot, great to hear 😄.

The installation problem you describe is indeed a bug - should not be necessary by default. @Leguark mentioned yesterday that it should be fixed today.

Kind regards and happy modeling!

JoostGevaert commented 5 months ago

Thanks for the quick reply, and great news that it'll be fixed soon!

AlexanderJuestel commented 5 months ago

Just encountered the same issue

pip install torch solves the issue until it is fixed in the requirements.

Leguark commented 5 months ago

It was a rogue import in the gempy engine. Just pushed a hotfix. Make sure to reinstall gempy_engine (v2024.1.4.1). Thanks for catching this up