NanoComp / meep

free finite-difference time-domain (FDTD) software for electromagnetic simulations
GNU General Public License v2.0
1.17k stars 598 forks source link

Conda missing scipy and matplotlib dependencies #2658

Closed SirNate0 closed 9 months ago

SirNate0 commented 9 months ago

Installing parallel meep as suggested in the documentation,

conda create -n pmp -c conda-forge pymeep=*=mpi_mpich_*

there seems to be a missing dependency on scipy. When I import meep, I get

Traceback (most recent call last):                                                                                  
  File "<stdin>", line 1, in <module>                                                                               
  File "/home/nathan/Tools/miniconda/envs/pmp/lib/python3.11/site-packages/meep/__init__.py", line 4250, in <module>
    from .simulation import (                                                                                       
  File "/home/nathan/Tools/miniconda/envs/pmp/lib/python3.11/site-packages/meep/simulation.py", line 12, in <module>
    from scipy.interpolate import pade                                                                              
ModuleNotFoundError: No module named 'scipy' 

After installing scipy, I found it is also missing a matplotlib dependency.

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/nathan/Tools/miniconda/envs/pmp/lib/python3.11/site-packages/meep/__init__.py", line 4250, in <module>
    from .simulation import (
  File "/home/nathan/Tools/miniconda/envs/pmp/lib/python3.11/site-packages/meep/simulation.py", line 45, in <module>
    from matplotlib.axes import Axes
ModuleNotFoundError: No module named 'matplotlib'
oskooi commented 9 months ago

To obtain the additional dependencies including Scipy and Matplotlib which are necessary for the tutorials, you will also need to install the pymeep-extras Conda package as described in the installation page.

SirNate0 commented 9 months ago

My issue with the current arrangement is that scipy/matplotlib are required just to import meep, and not only to run the tutorials. I.e. the meep package depends on them, but conda is not aware of this. At the very least, maybe add the pymeep-extras package to the suggested command for installing parallel meep?

A better option would probably be to make it so that meep can be imported without the (supposedly optional) dependencies. Particularly matplotlib, a large dependency which seems to only be needed to use Axes in a type annotation here (which seems to be possible without importing the class)

oskooi commented 9 months ago

scipy is a required dependency to enable the PadeApproximant feature which was recently added in #2440.

matplotlib is required for the visualization routines including plot2D. The documentation for this routine does state "Requires matplotlib."

It would be possible to import the Meep module without scipy and matplotlib but this would require some changes to the code. For now, we can simply make it clear in the installation page that installing the additional package pymeep-extras is recommended.

stevengj commented 9 months ago

The point is that the conda package for meep should list these dependencies, so that they get automatically installed.

oskooi commented 9 months ago

The point is that the conda package for meep should list these dependencies, so that they get automatically installed.

The pymeep Conda package now includes matplotlib and scipy (conda-forge/pymeep-feedstock#79).

(It will take a few hours for Conda forge to update this package.)