PyDMD / PyDMD

Python Dynamic Mode Decomposition

Home Page:https://pydmd.github.io/PyDMD/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Parts of pyDMD not importing properly

moonlians opened this issue · comments

Describe the bug
ImportError: cannot import name 'Havok' from 'pydmd' (C:\Users\x\anaconda3\envs\SVD\lib\site-packages\pydmd_init_.py)

Certain parts of pyDMD aren't importing properly. Havok, Plotter, and Snapshots all have this problem.
I have tried using a clean environment, and installing with pip and with cloning github.

Hi @moonlians, thank you for the report.

I'm going to try reproducing the problem, could you please dump the exact sequence of commands you're using (from git clone to where you try to import the modules, including also pip install). Thanks!

Thanks. I've used:
pip install pydmd

Then:
from pydmd import DMD
from pydmd import plotter
from pydmd import snapshots

HAVOK is now working - I was typing Havok not HAVOK, that was the problem there...

Then :
git clone https://github.com/mathLab/PyDMD
I then do cd PyDMD
and
python setup.py install
And then the above again:
from pydmd import DMD
from pydmd import plotter
from pydmd import snapshots

DMD and HAVOK are classes, and they are exposed in __init__ so you can import them with your syntax. However plotter and snapshots are modules, so you should this syntax instead:

import pydmd.plotter
import pydmd.snapshots

If for instance you wanted the class Snapshots from the module snapshots you could do:

# either this
import pydmd.snapshots
snapshots.Snapshots(... something ...)

# or this
from pydmd.snapshots import Snapshots
Snapshots(... something ...)

and the same for functions.

I'm still getting module not found:

File "C:\Users\x\AppData\Local\Temp\ipykernel_10788\788030302.py", line 1, in
import pydmd.plotter

ModuleNotFoundError: No module named 'pydmd.plotter'

File "C:\Users\x\AppData\Local\Temp\ipykernel_10788\2118356530.py", line 1, in
import pydmd.snapshots

ModuleNotFoundError: No module named 'pydmd.snapshots'

Strangely, HAVOK is also not working for me again now... I went back to my history to try to understand why it worked before, but I couldn't replicate it, sorry.

from pydmd import HAVOK

ImportError: cannot import name 'HAVOK' from 'pydmd' (C:\Users\x\anaconda3\envs\DMD\lib\site-packages\pydmd_init_.py)

snapshots and plotter are not yet distributed with the version you get with pip install pydmd. I suggest uninstalling PyDMD and then re-installing from source just to be sure. I did the following:

$ pip uninstall pydmd
$ git clone https://github.com/mathLab/PyDMD.git
$ pip install PyDMD/
$ python3
>>> import pydmd.snapshots
>>> import pydmd.plotter
>>> from pydmd import HAVOK

and I get no errors. I didn't use any virtual environment.

Thanks, that works!

I'm glad it works! Please re-open the issue if you encounter any other problem