calliope-project / euro-calliope

A workflow to build models of the European electricity system for Calliope.
https://euro-calliope.readthedocs.io
MIT License
31 stars 18 forks source link

"ImportError: pyutilib.enum has been removed" When Running Pre-Built Model #216

Closed zoltanmaric closed 2 years ago

zoltanmaric commented 2 years ago

What happened?

I'm trying to run pre-built-euro-calliope-v1.0/continental/example-model.yaml from the prebuilt models package on Ubuntu 20.04.4 LTS, but it seems it uses a version of pyomo that calls the removed module pyutilib.enum.

The pyomo version used is 5.6.8. Using 5.6.9 resulted in the same error, while 5.7 results in conflicting packages during environment creation.

This is what I did:

cd pre-built-euro-calliope-v1.0/
conda env create -f environment.yaml
conda activate euro-calliope
calliope run ./continental/example-model.yaml

Version

1.0.0

Relevant log output

Traceback (most recent call last):
  File "/home/zoltan/mambaforge/envs/euro-calliope-prebuilt/bin/calliope", line 6, in <module>
    from calliope.cli import cli
  File "/home/zoltan/mambaforge/envs/euro-calliope-prebuilt/lib/python3.7/site-packages/calliope/__init__.py", line 3, in <module>
    from calliope import examples, exceptions
  File "/home/zoltan/mambaforge/envs/euro-calliope-prebuilt/lib/python3.7/site-packages/calliope/examples.py", line 14, in <module>
    from calliope.core.model import Model
  File "/home/zoltan/mambaforge/envs/euro-calliope-prebuilt/lib/python3.7/site-packages/calliope/core/__init__.py", line 1, in <module>
    from calliope.core.model import Model, read_netcdf
  File "/home/zoltan/mambaforge/envs/euro-calliope-prebuilt/lib/python3.7/site-packages/calliope/core/model.py", line 33, in <module>
    from calliope.backend.run import run as run_backend
  File "/home/zoltan/mambaforge/envs/euro-calliope-prebuilt/lib/python3.7/site-packages/calliope/backend/run.py", line 14, in <module>
    from calliope.backend.pyomo import model as run_pyomo
  File "/home/zoltan/mambaforge/envs/euro-calliope-prebuilt/lib/python3.7/site-packages/calliope/backend/pyomo/model.py", line 15, in <module>
    import pyomo.core as po  # pylint: disable=import-error
  File "/home/zoltan/mambaforge/envs/euro-calliope-prebuilt/lib/python3.7/site-packages/pyomo/core/__init__.py", line 11, in <module>
    from pyomo.core.expr import *
  File "/home/zoltan/mambaforge/envs/euro-calliope-prebuilt/lib/python3.7/site-packages/pyomo/core/expr/__init__.py", line 36, in <module>
    from .calculus.derivatives import differentiate
  File "/home/zoltan/mambaforge/envs/euro-calliope-prebuilt/lib/python3.7/site-packages/pyomo/core/expr/calculus/derivatives.py", line 3, in <module>
    from pyutilib.enum import Enum
  File "/home/zoltan/mambaforge/envs/euro-calliope-prebuilt/lib/python3.7/site-packages/pyutilib/enum/__init__.py", line 18, in <module>
    package) that supersedes this library.""")
ImportError: pyutilib.enum has been removed.

Python 3 now has an enum implementation in the standard library (also
available for older Python versions as the third-party enum34 PyPI
package) that supersedes this library.
timtroendle commented 2 years ago

This is a known issue in v1.0 that is based on updated dependencies. It should not be an issue in v1.1.

If you must or want to use v1.0, you can fix the environment yourself: Simply fix pyutilib to v.5.8.0 by adding the line - pyutilib=5.8.0 to the environment file. This should solve your problem.

zoltanmaric commented 2 years ago

Thanks! I guess I was misled by the documentation pointing to the older version (1.0) of the prebuilt package, but I should have noticed the banner on Zenodo saying that there is a newer version available. Let me know if it helps if I submit a pull request with the updated link in the docs. I thought it wasn't such a big deal.

Running the prebuilt package v1.1.0 ran without problems. I'll close this issue.

timtroendle commented 2 years ago

That makes sense. Thanks for the catch, @zoltanmaric !