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

pybamm fails when running script a second time in spyder on windows #1479

Closed
TomTranter opened this issue May 7, 2021 · 6 comments · Fixed by #1555
Closed

pybamm fails when running script a second time in spyder on windows #1479

TomTranter opened this issue May 7, 2021 · 6 comments · Fixed by #1555
Assignees
Labels
bug Something isn't working

Comments

@TomTranter
Copy link
Contributor

Describe the bug
Running any script more than once seems to result in an import error because of the recent changes to parameters

File "", line 908, in _find_spec

AttributeError: 'ImportDenier' object has no attribute 'find_spec'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

File "C:\Users\tom\code\PyBaMM\examples\scripts\drive_cycle.py", line 14, in
param = model.default_parameter_values

File "c:\users\tom\code\pybamm\pybamm\models\full_battery_models\base_battery_model.py", line 346, in default_parameter_values
return pybamm.ParameterValues(chemistry=pybamm.parameter_sets.Marquis2019)

File "c:\users\tom\code\pybamm\pybamm\parameters\parameter_values.py", line 73, in init
self.update_from_chemistry(chemistry)

File "c:\users\tom\code\pybamm\pybamm\parameters\parameter_values.py", line 216, in update_from_chemistry
self.update(

File "c:\users\tom\code\pybamm\pybamm\parameters\parameter_values.py", line 301, in update
loaded_value = pybamm.load_function(os.path.join(path, value[10:]))

File "c:\users\tom\code\pybamm\pybamm\util.py", line 273, in load_function
module_object = importlib.import_module(path)

File "C:\Users\tom\anaconda3\lib\importlib_init_.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)

File "", line 1014, in _gcd_import

File "", line 991, in _find_and_load

File "", line 961, in _find_and_load_unlocked

File "", line 219, in _call_with_frames_removed

File "", line 1014, in _gcd_import

File "", line 991, in _find_and_load

File "", line 971, in _find_and_load_unlocked

File "", line 910, in _find_spec

File "", line 884, in _find_spec_legacy

File "C:\Users\tom\anaconda3\lib\site-packages\IPython\external\qt_loaders.py", line 48, in find_module
if path:

File "", line 1183, in len

File "", line 1162, in _recalculate

File "", line 1158, in _get_parent_path

KeyError: 'pybamm.input.parameters.lithium_ion'

@TomTranter TomTranter added the bug Something isn't working label May 7, 2021
@tlestang
Copy link
Contributor

tlestang commented May 7, 2021

Is this maybe related to #1475 ? @priyanshuone6 any ideas what is going wrong?

@tlestang
Copy link
Contributor

tlestang commented May 7, 2021

@TomTranter Could you provide a minimal example and steps to reproduce please?

@priyanshuone6
Copy link
Member

I could dig deeper after I get the steps to reproduce this bug

@TomTranter
Copy link
Contributor Author

I'm using spyder on windows - running any script twice without restarting the kernel results in the above error. Still happening - any ideas?

@TomTranter
Copy link
Contributor Author

Seems to be ok when I run example scripts from the pybamm directory but not scripts from another folder

@TomTranter
Copy link
Contributor Author

Think I fixed it by putting empty init files into all the parameter subfolders

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants