Closed sunt05 closed 1 week ago
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 climada
step cannot be attributed to the "simple installation" approach!
Usually this happens because the ipykernel is wrong. Have you checked that?
@sunt05 This looks like a mismatch between the versions of dask
and pandas
. As @emanuel-schmid already mentioned, you need to follow the Advanced Installation Instructions for running the script from #692. In step 4, replace
git checkout develop
with
git checkout calibrate-impact-functions
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
mamba install -n climada_env jupyter
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.
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:
python -m unittest climada.engine.test.test_impact
Many thanks, @sunt05! This is unexpected, normally numpy 1.xx is bein installed. I suppose you can workaround by running
mamba install numpy=1.26
Meanwhile we have to investigate this and likely update the environment file. To speed this up, could you perhaps post the output of
mamba repoquery whoneeds numpy
here?
Please see below for the output of mamba repoquery whoneeds numpy
:
Using local repodata...
Loaded current active prefix: "/Users/tingsun/micromamba/envs/climada_env"
No entries matching "numpy" found
numpy may not be installed. Try giving a channel with '-c,--channel' option for remote repoquery
From the above error message, it looks like the issue was caused by xarray
.
Also, after downgrading numpy
to 1.26, a new issue related to cartopy
and shapely
appeared when running the test python -m unittest climada.engine.test.test_impact
:
Traceback (most recent call last):
File "/Users/tingsun/micromamba/envs/climada_env/lib/python3.9/runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/Users/tingsun/micromamba/envs/climada_env/lib/python3.9/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/Users/tingsun/micromamba/envs/climada_env/lib/python3.9/unittest/__main__.py", line 18, in <module>
main(module=None)
File "/Users/tingsun/micromamba/envs/climada_env/lib/python3.9/unittest/main.py", line 100, in __init__
self.parseArgs(argv)
File "/Users/tingsun/micromamba/envs/climada_env/lib/python3.9/unittest/main.py", line 147, in parseArgs
self.createTests()
File "/Users/tingsun/micromamba/envs/climada_env/lib/python3.9/unittest/main.py", line 158, in createTests
self.test = self.testLoader.loadTestsFromNames(self.testNames,
File "/Users/tingsun/micromamba/envs/climada_env/lib/python3.9/unittest/loader.py", line 220, in loadTestsFromNames
suites = [self.loadTestsFromName(name, module) for name in names]
File "/Users/tingsun/micromamba/envs/climada_env/lib/python3.9/unittest/loader.py", line 220, in <listcomp>
suites = [self.loadTestsFromName(name, module) for name in names]
File "/Users/tingsun/micromamba/envs/climada_env/lib/python3.9/unittest/loader.py", line 154, in loadTestsFromName
module = __import__(module_name)
File "/Users/tingsun/Dropbox (Personal)/Mac/Downloads/20240617-climada/climada_python/climada/__init__.py", line 24, in <module>
from .util.config import CONFIG
File "/Users/tingsun/Dropbox (Personal)/Mac/Downloads/20240617-climada/climada_python/climada/util/__init__.py", line 26, in <module>
from .coordinates import *
File "/Users/tingsun/Dropbox (Personal)/Mac/Downloads/20240617-climada/climada_python/climada/util/coordinates.py", line 32, in <module>
from cartopy.io import shapereader
File "/Users/tingsun/micromamba/envs/climada_env/lib/python3.9/site-packages/cartopy/__init__.py", line 106, in <module>
import cartopy.crs # noqa: E402 module-level imports
File "/Users/tingsun/micromamba/envs/climada_env/lib/python3.9/site-packages/cartopy/crs.py", line 3020, in <module>
Sinusoidal.MODIS = Sinusoidal(globe=Globe(ellipse=None,
File "/Users/tingsun/micromamba/envs/climada_env/lib/python3.9/site-packages/cartopy/crs.py", line 2998, in __init__
self._boundary = sgeom.LinearRing(points)
File "/Users/tingsun/micromamba/envs/climada_env/lib/python3.9/site-packages/shapely/geometry/polygon.py", line 104, in __new__
geom = shapely.linearrings(coordinates)
File "/Users/tingsun/micromamba/envs/climada_env/lib/python3.9/site-packages/shapely/decorators.py", line 77, in wrapped
return func(*args, **kwargs)
File "/Users/tingsun/micromamba/envs/climada_env/lib/python3.9/site-packages/shapely/creation.py", line 171, in linearrings
return lib.linearrings(coords, out=out, **kwargs)
RecursionError: maximum recursion depth exceeded while calling a Python object
Er - sorry - but that doesn't look good. In particular the output of mamba repoquery
is inexplicable. I'm afraid something went wrong with the installation. At this point I'd suggest to restart from scratch. Do cd <path/to/workspace>
and run
cd climada_python
git checkout calibrate-impact-functions
git pull origin calibrate-impact-functions
mamba env remove -n climada_env
mamba create -n climada_env python=3.9
mamba env update -n climada_env -f requirements/env_climada.yml
mamba activate climada_env
python -m pip install -e "./[dev]"
If 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 numpy
command again and post the output.
Thanks for updated instructions.
Please see below:
❯ mamba repoquery whoneeds numpy
Using local repodata...
Loaded current active prefix: "/Users/tingsun/micromamba/envs/climada_env"
Name Version Build Depends Channel Subdir
────────────────────────────────────────────────────────────────────────────────
bokeh 3.4.1 pyhd8ed1ab_0 conda-forge noarch
bottleneck 1.4.0 py39h37867e2_0 conda-forge osx-arm64
cartopy 0.23.0 py39h998126f_1 conda-forge osx-arm64
cfgrib 0.9.9.1 pyhd8ed1ab_2 conda-forge noarch
cftime 1.6.4 py39h161d348_0 conda-forge osx-arm64
contourpy 1.2.1 py39h48c5dd5_0 conda-forge osx-arm64
dask 2024.2.1 pyhd8ed1ab_0 conda-forge noarch
fiona 1.9.1 py39h9e5269e_0 conda-forge osx-arm64
folium 0.17.0 pyhd8ed1ab_0 conda-forge noarch
gdal 3.6.2 py39h766d3fc_6 conda-forge osx-arm64
h5py 3.8.0 nompi_py39hc9149d8_100 conda-forge osx-arm64
mapclassify 2.6.1 pyhd8ed1ab_0 conda-forge noarch
matplotlib-base 3.8.4 py39h15359f4_2 conda-forge osx-arm64
netcdf4 1.6.2 nompi_py39h8ded8ba_100 conda-forge osx-arm64
numba 0.60.0 py39h2d4ef1e_0 conda-forge osx-arm64
numexpr 2.10.0 py39h998126f_0 conda-forge osx-arm64
pandas 2.1.4 py39hf8cecc8_0 conda-forge osx-arm64
patsy 0.5.6 pyhd8ed1ab_0 conda-forge noarch
pyarrow 12.0.1 py39hf40061a_7_cpu conda-forge osx-arm64
pytables 3.7.0 py39h8abd629_3 conda-forge osx-arm64
python-eccodes 1.5.1 py39h4d8bf0d_0 conda-forge osx-arm64
rasterio 1.3.6 py39h157378c_0 conda-forge osx-arm64
salib 1.5.0 pyhd8ed1ab_0 conda-forge noarch
scikit-learn 1.5.0 py39h3c33c8b_1 conda-forge osx-arm64
scipy 1.13.1 py39h3d5391c_0 conda-forge osx-arm64
seaborn-base 0.13.2 pyhd8ed1ab_2 conda-forge noarch
shapely 2.0.1 py39h472ea82_0 conda-forge osx-arm64
snuggs 1.4.7 py_0 conda-forge noarch
sparse 0.15.4 pyhd8ed1ab_0 conda-forge noarch
statsmodels 0.14.2 py39h161d348_0 conda-forge osx-arm64
xarray 2024.6.0 pyhd8ed1ab_1 conda-forge noarch
(climada_env)
BTW, now the issue comes from pandas
when running the test python -m unittest climada.engine.test.test_impact
:
Traceback (most recent call last):
File "/Users/tingsun/micromamba/envs/climada_env/lib/python3.9/runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/Users/tingsun/micromamba/envs/climada_env/lib/python3.9/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/Users/tingsun/micromamba/envs/climada_env/lib/python3.9/unittest/__main__.py", line 18, in <module>
main(module=None)
File "/Users/tingsun/micromamba/envs/climada_env/lib/python3.9/unittest/main.py", line 100, in __init__
self.parseArgs(argv)
File "/Users/tingsun/micromamba/envs/climada_env/lib/python3.9/unittest/main.py", line 147, in parseArgs
self.createTests()
File "/Users/tingsun/micromamba/envs/climada_env/lib/python3.9/unittest/main.py", line 158, in createTests
self.test = self.testLoader.loadTestsFromNames(self.testNames,
File "/Users/tingsun/micromamba/envs/climada_env/lib/python3.9/unittest/loader.py", line 220, in loadTestsFromNames
suites = [self.loadTestsFromName(name, module) for name in names]
File "/Users/tingsun/micromamba/envs/climada_env/lib/python3.9/unittest/loader.py", line 220, in <listcomp>
suites = [self.loadTestsFromName(name, module) for name in names]
File "/Users/tingsun/micromamba/envs/climada_env/lib/python3.9/unittest/loader.py", line 154, in loadTestsFromName
module = __import__(module_name)
File "/Users/tingsun/Dropbox (Personal)/Mac/Downloads/20240617-climada/climada_python/climada/__init__.py", line 24, in <module>
from .util.config import CONFIG
File "/Users/tingsun/Dropbox (Personal)/Mac/Downloads/20240617-climada/climada_python/climada/util/__init__.py", line 26, in <module>
from .coordinates import *
File "/Users/tingsun/Dropbox (Personal)/Mac/Downloads/20240617-climada/climada_python/climada/util/coordinates.py", line 33, in <module>
import dask.dataframe as dd
File "/Users/tingsun/.local/lib/python3.9/site-packages/dask/dataframe/__init__.py", line 4, in <module>
from dask.dataframe import backends, dispatch, rolling
File "/Users/tingsun/.local/lib/python3.9/site-packages/dask/dataframe/backends.py", line 21, in <module>
from dask.dataframe.core import DataFrame, Index, Scalar, Series, _Frame
File "/Users/tingsun/.local/lib/python3.9/site-packages/dask/dataframe/core.py", line 35, in <module>
from dask.dataframe import methods
File "/Users/tingsun/.local/lib/python3.9/site-packages/dask/dataframe/methods.py", line 22, in <module>
from dask.dataframe.utils import is_dataframe_like, is_index_like, is_series_like
File "/Users/tingsun/.local/lib/python3.9/site-packages/dask/dataframe/utils.py", line 19, in <module>
from dask.dataframe import ( # noqa: F401 register pandas extension types
File "/Users/tingsun/.local/lib/python3.9/site-packages/dask/dataframe/_dtypes.py", line 3, in <module>
from dask.dataframe.extensions import make_array_nonempty, make_scalar
File "/Users/tingsun/.local/lib/python3.9/site-packages/dask/dataframe/extensions.py", line 6, in <module>
from dask.dataframe.accessor import (
File "/Users/tingsun/.local/lib/python3.9/site-packages/dask/dataframe/accessor.py", line 190, in <module>
class StringAccessor(Accessor):
File "/Users/tingsun/.local/lib/python3.9/site-packages/dask/dataframe/accessor.py", line 276, in StringAccessor
pd.core.strings.StringMethods,
AttributeError: module 'pandas.core.strings' has no attribute 'StringMethods'
(climada_env)
Also the info about pandas
:
pandas 2.1.4 py39hf8cecc8_0 conda-forge
@sunt05 This still does not look right. Note that the traceback shows that the dask
module 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?
I see - thanks for pointing that out - will switch now and update you shortly.
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.
👍 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.
@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
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:
The issue was occurring while importing
climada
:The issue seems to be related to an upstream package.