PLAMS
PLAMS copied to clipboard
Circular import error while using PLAMS
Hi SCM,
I have updated my local branch to catch up with new developments. After the 'git pull' and a successful install 'python setup.py install', I have the following error in one recipe trying to import the library:
> from scm.plams import *
> ---------------------------------------------------------------------------
> ImportError Traceback (most recent call last)
> <ipython-input-2-e8bc99e0fde1> in <module>
> ----> 1 from scm.plams import *
>
> ~/Programs/miniconda3/envs/osp/lib/python3.9/site-packages/plams-1.5.1-py3.9.egg/scm/plams/__init__.py in <module>
> 19
> 20
> ---> 21 __all__ = __autoimport(__path__[0], ['core', 'mol', 'interfaces', 'tools', 'recipes','trajectories'])
> 22
> 23 __version__ = '1.5.1'
>
> ~/Programs/miniconda3/envs/osp/lib/python3.9/site-packages/plams-1.5.1-py3.9.egg/scm/plams/__init__.py in __autoimport(path, folders)
> 11 for module in modules:
> 12 imp = '.'.join(relpath + [module])
> ---> 13 tmp = __import__(imp, globals=globals(), fromlist=['*'], level=1)
> 14 if hasattr(tmp, '__all__'):
> 15 ret += tmp.__all__
>
> ~/Programs/miniconda3/envs/osp/lib/python3.9/site-packages/plams-1.5.1-py3.9.egg/scm/plams/recipes/pestools/optimizer.py in <module>
> 13 from scm.plams import FileError
> 14 from scm.plams import PlamsError
> ---> 15 from scm.plams import AMSWorkerPool
> 16 from scm.plams import AMSWorker
> 17 from scm.plams import JobRunner
>
> ImportError: cannot import name 'AMSWorkerPool' from partially initialized module 'scm.plams' (most likely due to a circular import) (/Users/plopez/Programs/miniconda3/envs/osp/lib/python3.9/site-packages/plams-1.5.1-py3.9.egg/scm/plams/__init__.py)
Do you know how I can solve the issue?
Thanks, Pablo
A temporary workaround is to edit the code
from
from scm.plams.amsworker import AMSWorkerPool
from scm.plams.amsworker import AMSWorker
to
from scm.plams.interfaces.adfsuite.amsworker import AMSWorkerPool
from scm.plams.interfaces.adfsuite.amsworker import AMSWorker
But not sure how can such a basic issue (importing libraries) has not been tackled before its release.
Hi @damdaepark , thanks for your suggestion the workaround works. I leave the issue open until the imports are fixed.
Thanks for flagging this issue Pablo.
The import issue was fixed here
So I am marking this issue as resolved.