MartinPdeS / PyMieSim

Python package for Mie scattering computation and analysis.
MIT License
18 stars 5 forks source link

Import Sphere from PyMieSim.scatterer fails #13

Closed Cr-St closed 8 months ago

Cr-St commented 9 months ago

Hello, I went through the PyMieSim and it is a great job, congrats!

I installed PyMieSim after cloning the repository locally. I try to follow the SPF computation example, but it fails. See below the error message:

❯ python PyMieSim/mesh.py
Traceback (most recent call last):
  File "/home/stathaki/EPFL/Simulations/PyMieSim/PyMieSim/mesh.py", line 7, in <module>
    from PyMieSim.binary.Fibonacci import FIBONACCI
ModuleNotFoundError: No module named 'PyMieSim.binary.Fibonacci'

Also from inside an ipython session:

In [1]: from PyMieSim.scatterer import Sphere
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
Cell In[1], line 1
----> 1 from PyMieSim.scatterer import Sphere

File ~/EPFL/Simulations/PyMieSim/.direnv/python-3.10.12/lib/python3.10/site-packages/PyMieSim/scatterer.py:10
      7 from tabulate import tabulate
      9 from PyOptik import ExpData
---> 10 from PyMieSim.mesh import FibonacciMesh
     11 from PyMieSim.source import PlaneWave
     12 from PyMieSim.representations import S1S2, FarField, Stokes, SPF, Footprint

File ~/EPFL/Simulations/PyMieSim/.direnv/python-3.10.12/lib/python3.10/site-packages/PyMieSim/mesh.py:7
      4 import numpy
      5 from dataclasses import dataclass
----> 7 from PyMieSim.binary.Fibonacci import FIBONACCI
      8 from MPSPlots.render3D import SceneList as SceneList3D
     11 @dataclass
     12 class FibonacciMesh():

ModuleNotFoundError: No module named 'PyMieSim.binary.Fibonacci'

What am I doing wrong?

Thank you

MartinPdeS commented 9 months ago

Hey hi. Thank you so much for reporting this, I am glad to hear from interested people.

Before delving into the problem, I'd like to ask why don't you just do a: >>> pip install PyMieSim

Now, to get over the problem here, I'll need some information.

>>> git clone https://github.com/MartinPdeS/PyMieSim.git
>>> cd PyMieSim
>>> git submodule init && git submodule update
>>> mkdir build
>>> cd build
>>> cmake ../ -G"Unix MakeFiles" (macOS, Linux)
>>> cmake ../ -G"MinGW MakeFiles" (Windows)
>>> sudo make install
>>> cd ..
>>> python -m pip install .
Cr-St commented 9 months ago

Hi again, Thank you for the prompt response.

On my first try, I did pip install PyMieSim and didn't work. I use Linux (Ubuntu 22.04).

See the result below:

❯ cmake ../ -G"Unix MakeFiles"
CMake Error: Could not create named generator Unix MakeFiles

Generators
  Green Hills MULTI            = Generates Green Hills MULTI files
                                 (experimental, work-in-progress).
* Unix Makefiles               = Generates standard UNIX makefiles.
  Ninja                        = Generates build.ninja files.
  Ninja Multi-Config           = Generates build-<Config>.ninja files.
  Watcom WMake                 = Generates Watcom WMake makefiles.
  CodeBlocks - Ninja           = Generates CodeBlocks project files.
  CodeBlocks - Unix Makefiles  = Generates CodeBlocks project files.
  CodeLite - Ninja             = Generates CodeLite project files.
  CodeLite - Unix Makefiles    = Generates CodeLite project files.
  Eclipse CDT4 - Ninja         = Generates Eclipse CDT 4.0 project files.
  Eclipse CDT4 - Unix Makefiles= Generates Eclipse CDT 4.0 project files.
  Kate - Ninja                 = Generates Kate project files.
  Kate - Unix Makefiles        = Generates Kate project files.
  Sublime Text 2 - Ninja       = Generates Sublime Text 2 project files.
  Sublime Text 2 - Unix Makefiles
                               = Generates Sublime Text 2 project files.

and the second command obviously fails

❯ sudo make install
make: *** No rule to make target 'install'.  Stop.
MartinPdeS commented 9 months ago

Ah, okay, I see. The command argument should indeed be: cmake ../ -G"Unix Makefiles" (notice the lowercase f)

Can you try this?

Also can you copy here the output of pip install PyMieSim. A pre-compiled version for ManyLinux2014 exists for x86_64. Are you running on arm64 or other exotic hardware?

Cr-St commented 9 months ago

The compilation was completed successfully. Thank you for assisting me!

Before I install it, is there any uninstall script in case I want to remove the software cleanly?

MartinPdeS commented 8 months ago

Sorry for the delayed response. I am glad it worked out. To clean the computer from PyMieSim you can simply delete the folder you cloned and, if you did a Python setup.py install or a pip install . then you should run pip uninstall PyMieSim.