Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImportError: cannot import name 'SolverLU' from 'SimPEG' #888

Closed
adamkosik opened this issue Jun 4, 2020 · 3 comments
Closed

ImportError: cannot import name 'SolverLU' from 'SimPEG' #888

adamkosik opened this issue Jun 4, 2020 · 3 comments

Comments

@adamkosik
Copy link
Contributor

adamkosik commented Jun 4, 2020

With the new version 0.14.0 I obtain this error on initialization of SimPEG.

I am not using Pardiso and the SolverLU has not been imported in SimPEG yet. I solved it by prepending the import of the Solvers to the import of the simulation in __init__.py.

>>> import SimPEG
Traceback (most recent call last):
  File "D:\Anaconda3\envs\REX_0_14_0\lib\site-packages\SimPEG\simulation.py", line 21, in <module>
    from pymatsolver import Pardiso as DefaultSolver
ImportError: cannot import name 'Pardiso' from 'pymatsolver' (D:\Anaconda3\envs\REX_0_14_0\lib\site-packages\pymatsolver\__init__.py)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "D:\Anaconda3\envs\REX_0_14_0\lib\site-packages\SimPEG\__init__.py", line 9, in <module>
    from . import data_misfit
  File "D:\Anaconda3\envs\REX_0_14_0\lib\site-packages\SimPEG\data_misfit.py", line 5, in <module>
    from .simulation import BaseSimulation
  File "D:\Anaconda3\envs\REX_0_14_0\lib\site-packages\SimPEG\simulation.py", line 23, in <module>
    from SimPEG import SolverLU as DefaultSolver
ImportError: cannot import name 'SolverLU' from 'SimPEG' (D:\Anaconda3\envs\REX_0_14_0\lib\site-packages\SimPEG\__init__.py)
@adamkosik
Copy link
Contributor Author

The proposed solution is just a workaround. Probably better is to change imports in simulation.py to :

try:
    from pymatsolver import Pardiso as DefaultSolver
except ImportError:
    from .utils.solver_utils import SolverLU as DefaultSolver

instead of

try:
    from pymatsolver import Pardiso as DefaultSolver
except ImportError:
    from SimPEG import SolverLU as DefaultSolver

@jcapriot
Copy link
Member

jcapriot commented Jun 4, 2020

Thanks for catching this, it’s not often that we (the SimPEG developers) are in an environment that cannot import the pardiso solver, and this wasn’t checked.

Do you have details on your installation method? The pardiso solver should work when installing through conda-forge.

@adamkosik
Copy link
Contributor Author

adamkosik commented Jun 4, 2020

I have used pip 20.0.2, Python 3.7, Win 10. But you are right, the pardiso solver works when installed through conda-forge.

Anyway, that is how I discovered the import error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants