Repository navigation
Closed
Description
Hi, I'm trying to run the notebook associated with #692 but can't move forward.
I followed this guide for the installation of CLIMADA. Below is the version info:
CLIMADA Version: 4.1.0
python: 3.9.18
The issue was occurring while importing climada:
import logging
import climada
logging.getLogger("climada").setLevel("WARNING")The issue seems to be related to an upstream package.
Details
{
"name": "AttributeError",
"message": "module 'pandas.core.strings' has no attribute 'StringMethods'",
"stack": "---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
Cell In[1], line 2
1 import logging
----> 2 import climada
4 logging.getLogger(\"climada\").setLevel(\"WARNING\")
File ~/micromamba/envs/climada/lib/python3.9/site-packages/climada/__init__.py:24
21 from shutil import copyfile
22 from pathlib import Path
---> 24 from .util.config import CONFIG
25 from .util.constants import *
28 GSDP_DIR = SYSTEM_DIR.joinpath('GSDP')
File ~/micromamba/envs/climada/lib/python3.9/site-packages/climada/util/__init__.py:26
24 from .config import *
25 from .constants import *
---> 26 from .coordinates import *
27 from .save import *
29 ureg = UnitRegistry()
File ~/micromamba/envs/climada/lib/python3.9/site-packages/climada/util/coordinates.py:33
30 import zipfile
32 from cartopy.io import shapereader
---> 33 import dask.dataframe as dd
34 import geopandas as gpd
35 import numba
File ~/.local/lib/python3.9/site-packages/dask/dataframe/__init__.py:4
2 import dask.dataframe._pyarrow_compat
3 from dask.base import compute
----> 4 from dask.dataframe import backends, dispatch, rolling
5 from dask.dataframe.core import (
6 DataFrame,
7 Index,
(...)
13 to_timedelta,
14 )
15 from dask.dataframe.groupby import Aggregation
File ~/.local/lib/python3.9/site-packages/dask/dataframe/backends.py:21
19 from dask.array.percentile import _percentile
20 from dask.backends import CreationDispatch, DaskBackendEntrypoint
---> 21 from dask.dataframe.core import DataFrame, Index, Scalar, Series, _Frame
22 from dask.dataframe.dispatch import (
23 categorical_dtype_dispatch,
24 concat,
(...)
36 union_categoricals_dispatch,
37 )
38 from dask.dataframe.extensions import make_array_nonempty, make_scalar
File ~/.local/lib/python3.9/site-packages/dask/dataframe/core.py:35
33 from dask.blockwise import Blockwise, BlockwiseDep, BlockwiseDepDict, blockwise
34 from dask.context import globalmethod
---> 35 from dask.dataframe import methods
36 from dask.dataframe._compat import (
37 PANDAS_GT_140,
38 PANDAS_GT_150,
39 check_numeric_only_deprecation,
40 )
41 from dask.dataframe.accessor import CachedAccessor, DatetimeAccessor, StringAccessor
File ~/.local/lib/python3.9/site-packages/dask/dataframe/methods.py:22
10 # preserve compatibility while moving dispatch objects
11 from dask.dataframe.dispatch import ( # noqa: F401
12 concat,
13 concat_dispatch,
(...)
20 union_categoricals,
21 )
---> 22 from dask.dataframe.utils import is_dataframe_like, is_index_like, is_series_like
24 # cuDF may try to import old dispatch functions
25 hash_df = hash_object_dispatch
File ~/.local/lib/python3.9/site-packages/dask/dataframe/utils.py:19
17 from dask.base import get_scheduler, is_dask_collection
18 from dask.core import get_deps
---> 19 from dask.dataframe import ( # noqa: F401 register pandas extension types
20 _dtypes,
21 methods,
22 )
23 from dask.dataframe._compat import PANDAS_GT_110, PANDAS_GT_120, tm # noqa: F401
24 from dask.dataframe.dispatch import ( # noqa : F401
25 make_meta,
26 make_meta_obj,
27 meta_nonempty,
28 )
File ~/.local/lib/python3.9/site-packages/dask/dataframe/_dtypes.py:3
1 import pandas as pd
----> 3 from dask.dataframe.extensions import make_array_nonempty, make_scalar
6 @make_array_nonempty.register(pd.DatetimeTZDtype)
7 def _(dtype):
8 return pd.array([pd.Timestamp(1), pd.NaT], dtype=dtype)
File ~/.local/lib/python3.9/site-packages/dask/dataframe/extensions.py:6
1 \"\"\"
2 Support for pandas ExtensionArray in dask.dataframe.
3
4 See :ref:`extensionarrays` for more.
5 \"\"\"
----> 6 from dask.dataframe.accessor import (
7 register_dataframe_accessor,
8 register_index_accessor,
9 register_series_accessor,
10 )
11 from dask.utils import Dispatch
13 make_array_nonempty = Dispatch(\"make_array_nonempty\")
File ~/.local/lib/python3.9/site-packages/dask/dataframe/accessor.py:190
129 _accessor_methods = (
130 \"asfreq\",
131 \"ceil\",
(...)
145 \"tz_localize\",
146 )
148 _accessor_properties = (
149 \"components\",
150 \"date\",
(...)
186 \"year\",
187 )
--> 190 class StringAccessor(Accessor):
191 \"\"\"Accessor object for string properties of the Series values.
192
193 Examples
(...)
196 >>> s.str.lower() # doctest: +SKIP
197 \"\"\"
199 _accessor_name = \"str\"
File ~/.local/lib/python3.9/site-packages/dask/dataframe/accessor.py:276, in StringAccessor()
272 meta = (self._series.name, object)
273 return self._function_map(method, pat=pat, n=n, expand=expand, meta=meta)
275 @derived_from(
--> 276 pd.core.strings.StringMethods,
277 inconsistencies=\"``expand=True`` with unknown ``n`` will raise a ``NotImplementedError``\",
278 )
279 def split(self, pat=None, n=-1, expand=False):
280 \"\"\"Known inconsistencies: ``expand=True`` with unknown ``n`` will raise a ``NotImplementedError``.\"\"\"
281 return self._split(\"split\", pat=pat, n=n, expand=expand)
AttributeError: module 'pandas.core.strings' has no attribute 'StringMethods'"
}
Metadata
Metadata
Assignees
Labels
No labels
Activity
emanuel-schmid commentedon Jun 20, 2024
Thanks for reporting this @sunt05.
In order to run this notebook you will eventually have to switch to the "advanced installation" method, as you will need to install climada from sources (from the calibrate-impact-function branch, to be more precise).
However failing at the
import climadastep cannot be attributed to the "simple installation" approach!Usually this happens because the ipykernel is wrong. Have you checked that?
peanutfun commentedon Jun 21, 2024
@sunt05 This looks like a mismatch between the versions of
daskandpandas. As @emanuel-schmid already mentioned, you need to follow the Advanced Installation Instructions for running the script from #692. In step 4, replacewith
and continue with the instructions. Following them will not install Jupyter into the environment, so you can then choose to install Jupyterlab or install the more lightweight Jupyter with
You should then be ready to execute the tutorial. In any case, you should choose the Conda environment of Climada as Kernel when you run Jupyter.
Please report back if the problem persists when following these instructions. In this case, we might need to update the environment specifications.
sunt05 commentedon Jun 23, 2024
Many thanks for the guidance above.
However, I now encounter a new error when running verification after installing
climada, which should be addressed as numpy 2.0 has been formally released:Details
emanuel-schmid commentedon Jun 24, 2024
Many thanks, @sunt05! This is unexpected, normally numpy 1.xx is bein installed. I suppose you can workaround by running
Meanwhile we have to investigate this and likely update the environment file. To speed this up, could you perhaps post the output of
here?
sunt05 commentedon Jun 24, 2024
Please see below for the output of
mamba repoquery whoneeds numpy:From the above error message, it looks like the issue was caused by
xarray.sunt05 commentedon Jun 24, 2024
Also, after downgrading
numpyto 1.26, a new issue related tocartopyandshapelyappeared when running the testpython -m unittest climada.engine.test.test_impact:emanuel-schmid commentedon Jun 24, 2024
Er - sorry - but that doesn't look good. In particular the output of
mamba repoqueryis inexplicable. I'm afraid something went wrong with the installation. At this point I'd suggest to restart from scratch. Docd <path/to/workspace>and runIf you get an error for any of the commands, please post the command and error output here.
If all goes smoothly, run the
mamba repoquery whoneeds numpycommand again and post the output.sunt05 commentedon Jun 24, 2024
Thanks for updated instructions.
Please see below:
sunt05 commentedon Jun 24, 2024
BTW, now the issue comes from
pandaswhen running the testpython -m unittest climada.engine.test.test_impact:Also the info about
pandas:peanutfun commentedon Jun 24, 2024
@sunt05 This still does not look right. Note that the traceback shows that the
daskmodule loaded by your interpreter is located in/Users/tingsun/.local/lib/python3.9/site-packages/dask/(your default interpeter location, I presume), and not in the Mamba environment/Users/tingsun/micromamba/envs/climada_env.It seems you are using Micromamba, and we have no experience with its particular behavior. Can you switch to Conda or Mamba?
sunt05 commentedon Jun 24, 2024
I see - thanks for pointing that out - will switch now and update you shortly.
sunt05 commentedon Jun 24, 2024
Thanks for the above instructions - I just managed to install the package and run the entire impact notebook.
One suggestion for the installation instruction is to change the recommended Python version from 3.9 to 3.11, as the latter has better compatibility for ARM64 Mac. Python 3.9 has various issues due to several packages lacking ARM libraries for legacy reasons.
I'll now close this issue and move forward with the review task.
emanuel-schmid commentedon Jun 25, 2024
👍 Glad it worked out. Thanks for the suggestion. We wanted to do that anyway, eventually. Considering your input this should happen rather sooner than later.
peanutfun commentedon Jun 25, 2024
@sunt05 Thanks for the suggestion. We are currently blocked from updating to Python 3.12, see #868 #870. But it might be worthwhile to immediately jump to Python 3.11 as the supported version. @emanuel-schmid, this might then also bring us better in line with the Euler cluster setup. We can discuss that in the next dev meeting