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 'Dict' from 'pypsa.descriptors' #1349

Closed
fhg-isi opened this issue Oct 7, 2024 · 2 comments
Closed

ImportError: cannot import name 'Dict' from 'pypsa.descriptors' #1349

fhg-isi opened this issue Oct 7, 2024 · 2 comments
Labels

Comments

@fhg-isi
Copy link
Contributor

fhg-isi commented Oct 7, 2024

Checklist

  • [x ] I am using the current master branch or the latest release. Please indicate.
  • [x ] I am running on an up-to-date pypsa-eur environment. Update via conda env update -f envs/environment.yaml.

Describe the Bug

When trying to run prepare_sector_network.py as standalone script (while trying do debug some other issue), I get

ImportError: cannot import name 'Dict' from 'pypsa.descriptors' (/home/projekt-resilient03/conda/envs/pypsa-eur/lib/python3.12/site-packages/pypsa/descriptors.py)

The file
https://github.com/PyPSA/PyPSA/blob/master/pypsa/descriptors.py
does not contain a class "Dict" in its current version.

=>

a) Please update pypsa-eur to be compatible to the latest version of pypsa.

b) Please adapt tutorial documentation to use environment.fixed.yml instead of environment.yml (or
update version ranges of environment.yml to ensure that all code can be run without version issues).

c) Please implement some automated quality check pipeline/GitHub workflow to fail fast, if such version conflicts should occur in the future again. The quality assurance workflow should inform developers via email, if their changes are causing any issue for the resources needed by the beginner tutorials.

Related:

#1347

#1118

@fhg-isi fhg-isi added the bug label Oct 7, 2024
@jotisl
Copy link

jotisl commented Oct 7, 2024

For what it's worth, I was able to resolve this error while working in table_pypsa by switching a reference to pypsa.descriptors.Dict to pypsa.descriptors.OrderedDict, which I tried based on console inspection.

Maybe this could help with this particular error? It seemed to be sufficient here.

However I agree troubleshooting through a stack of changing packages has been a hurdle, but I am too much of a novice to know whether this is an "easy" fix.

@lkstrp
Copy link
Member

lkstrp commented Oct 29, 2024

Thanks @fhg-isi and @jotisl!
You are both very right. The issue was fixed in #1340, and #1389 introduces an up-to-date pinned environment where these things should no longer happen.
There are also plans to add a check to see if your local env matches the current pinned one (optional), which should fix all sorts of dependency issues once and for all.

@lkstrp lkstrp closed this as completed Oct 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants