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

[Dependency] ModuleNotFoundError: No module named 'xarray' #279

Closed
VoyagerXvoyagerx opened this issue May 9, 2024 · 0 comments · Fixed by #280
Closed

[Dependency] ModuleNotFoundError: No module named 'xarray' #279

VoyagerXvoyagerx opened this issue May 9, 2024 · 0 comments · Fixed by #280
Labels
bug Something isn't working

Comments

@VoyagerXvoyagerx
Copy link

Thanks for your great work! I had trouble in the environment setting when I got start with this repo.

Environment Information

  • samgeo version: 0.10.5
  • Python version: 3.10.0
  • leafmap: 0.31.9
  • Operating System: Ubuntu 22.04.3 LTS

Description

I failed to add geotif image to the basemap.

---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
Cell In[7], [line 2](vscode-notebook-cell:?execution_count=7&line=2)
      [1](vscode-notebook-cell:?execution_count=7&line=1) m.layers[-1].visible = False
----> [2](vscode-notebook-cell:?execution_count=7&line=2) m.add_raster(image, layer_name="Image")
      [3](vscode-notebook-cell:?execution_count=7&line=3) m

File /data1/anaconda3/envs/samgeopip/lib/python3.10/site-packages/leafmap/leafmap.py:2250, in Map.add_raster(self, source, indexes, colormap, vmin, vmax, nodata, attribution, layer_name, zoom_to_layer, visible, array_args, **kwargs)
   [2228](https://vscode-remote+ssh-002dremote-002b10-002e3-002e100-002e160.vscode-resource.vscode-cdn.net/data1/anaconda3/envs/samgeopip/lib/python3.10/site-packages/leafmap/leafmap.py:2228) """Add a local raster dataset to the map.
   [2229](https://vscode-remote+ssh-002dremote-002b10-002e3-002e100-002e160.vscode-resource.vscode-cdn.net/data1/anaconda3/envs/samgeopip/lib/python3.10/site-packages/leafmap/leafmap.py:2229)     If you are using this function in JupyterHub on a remote server (e.g., Binder, Microsoft Planetary Computer) and
   [2230](https://vscode-remote+ssh-002dremote-002b10-002e3-002e100-002e160.vscode-resource.vscode-cdn.net/data1/anaconda3/envs/samgeopip/lib/python3.10/site-packages/leafmap/leafmap.py:2230)     if the raster does not render properly, try installing jupyter-server-proxy using `pip install jupyter-server-proxy`,
   (...)
   [2247](https://vscode-remote+ssh-002dremote-002b10-002e3-002e100-002e160.vscode-resource.vscode-cdn.net/data1/anaconda3/envs/samgeopip/lib/python3.10/site-packages/leafmap/leafmap.py:2247)     array_args (dict, optional): Additional arguments to pass to `array_to_memory_file` when reading the raster. Defaults to {}.
   [2248](https://vscode-remote+ssh-002dremote-002b10-002e3-002e100-002e160.vscode-resource.vscode-cdn.net/data1/anaconda3/envs/samgeopip/lib/python3.10/site-packages/leafmap/leafmap.py:2248) """
   [2249](https://vscode-remote+ssh-002dremote-002b10-002e3-002e100-002e160.vscode-resource.vscode-cdn.net/data1/anaconda3/envs/samgeopip/lib/python3.10/site-packages/leafmap/leafmap.py:2249) import numpy as np
-> [2250](https://vscode-remote+ssh-002dremote-002b10-002e3-002e100-002e160.vscode-resource.vscode-cdn.net/data1/anaconda3/envs/samgeopip/lib/python3.10/site-packages/leafmap/leafmap.py:2250) import xarray as xr
   [2252](https://vscode-remote+ssh-002dremote-002b10-002e3-002e100-002e160.vscode-resource.vscode-cdn.net/data1/anaconda3/envs/samgeopip/lib/python3.10/site-packages/leafmap/leafmap.py:2252) if isinstance(source, np.ndarray) or isinstance(source, xr.DataArray):
   [2253](https://vscode-remote+ssh-002dremote-002b10-002e3-002e100-002e160.vscode-resource.vscode-cdn.net/data1/anaconda3/envs/samgeopip/lib/python3.10/site-packages/leafmap/leafmap.py:2253)     source = array_to_image(source, **array_args)

ModuleNotFoundError: No module named 'xarray'

What I Did

Reproduce the bug

I created a new conda environment, and use pip install segment-geospatial to install the segment-geospatial package.
When installing segment-geospatial, it was reported that

ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
docker-compose 1.29.2 requires distro<2,>=1.5.0, which is not installed.
docker-compose 1.29.2 requires jsonschema<4,>=2.5.1, but you have jsonschema 4.22.0 which is incompatible.
docker-compose 1.29.2 requires PyYAML<6,>=3.10, but you have pyyaml 6.0.1 which is incompatible.
docker-compose 1.29.2 requires websocket-client<1,>=0.32.0, but you have websocket-client 1.8.0 which is incompatible.

other packages were successfully installed.

when executing the following code block in the example notebook automatic_mask_generator.ipynb

m.layers[-1].visible = False
m.add_raster(image, layer_name="Image")
m

Fix the bug

After installing pip install xarray, I could seccessfully excecute the code block.
I guess it's a dependency issue. Shall we add the package xarray to the requirements.txt?

@VoyagerXvoyagerx VoyagerXvoyagerx added the bug Something isn't working label May 9, 2024
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.

1 participant