Closed zwy1502 closed 3 months ago
This is your localtileserver installtion issue. Try import localtileserver
. If it does not work, create a new fresh conda env and use the following command to install packages.
https://localtileserver.banesullivan.com/installation/index.html#installing-with-conda
conda install -c conda-forge localtileserver geemap
This is your localtileserver installtion issue. Try
import localtileserver
. If it does not work, create a new fresh conda env and use the following command to install packages.https://localtileserver.banesullivan.com/installation/index.html#installing-with-conda
conda install -c conda-forge localtileserver geemap
Teacher, I installed Geemap according to the code in your book and ran these codes separately: conda create -n gee python conda activate gee conda install -c conda-forge mamba mamba install -c conda-forge geemap pygis
In the following answer, I refer to the environment in which the four lines of code run as Gee
After running these codes, I did not take any other actions. Currently, I have provided you with feedback that the issue is based on reinstalling a Gee environment from my four lines of code and running it again: Map. add_raster (file name,...), vis_params=vis_params, layer_name='Local Image')。 The program will report an error about the localileserver library.
ImportError Traceback (most recent call last) File D:\software\anaconda\envs\gee\Lib\site-packages\flask_restx\api.py:18 17 try: ---> 18 from flask.helpers import _endpoint_from_view_func 19 except ImportError:
ImportError: cannot import name '_endpoint_from_view_func' from 'flask.helpers' (D:\software\anaconda\envs\gee\Lib\site-packages\flask\helpers.py)
During handling of the above exception, another exception occurred:
ModuleNotFoundError Traceback (most recent call last) Cell In[1], line 1 ----> 1 import localtileserver
File D:\software\anaconda\envs\gee\Lib\site-packages\localtileserver__init_.py:3 1 # flake8: noqa: F401 2 from localtileserver. version import version ----> 3 from localtileserver.client import TileClient, get_or_create_tile_client 4 from localtileserver.helpers import hillshade, parse_shapely, polygon_to_geojson, save_new_raster 5 from localtileserver.report import Report
File D:\software\anaconda\envs\gee\Lib\site-packages\localtileserver\client.py:22 19 from server_thread import ServerManager, launch_server 21 from localtileserver.configure import get_default_client_params ---> 22 from localtileserver.manager import AppManager 23 from localtileserver.tiler import ( 24 format_to_encoding, 25 get_building_docs, (...) thirty-two palette_valid_or_raise, 33 ) 34 from localtileserver.utilities import add_query_parameters
File D:\software\anaconda\envs\gee\Lib\site-packages\localtileserver\manager.py:1 ----> 1 from localtileserver.web import create_app 4 class AppManager: 5 _APP = None
File D:\software\anaconda\envs\gee\Lib\site-packages\localtileserver\web__init__.py:2 1 # flake8: noqa: F401 ----> 2 from localtileserver.web import rest, urls, views 3 from localtileserver.web.application import create_app, run_app 4 from localtileserver.web.blueprint import cache, tileserver
File D:\software\anaconda\envs\gee\Lib\site-packages\localtileserver\web\rest.py:4 1 import io 3 from flask import request, send_file ----> 4 from flask_restx import Api, Resource as View 5 from rasterio import RasterioIOError 6 from rio_tiler.errors import TileOutsideBounds
File D:\software\anaconda\envs\gee\Lib\site-packages\flask_restx__init__.py:2 1 from . import fields, reqparse, apidoc, inputs, cors ----> 2 from .api import Api # noqa 3 from .marshalling import marshal, marshal_with, marshal_with_field # noqa 4 from .mask import Mask
File D:\software\anaconda\envs\gee\Lib\site-packages\flask_restx\api.py:20 eighteen from flask.helpers import _endpoint_from_view_func 19 except ImportError: ---> 20 from flask.scaffold import _endpoint_from_view_func 21 from flask.signals import got_request_exception 23 from jsonschema import RefResolver
ModuleNotFoundError: No module named 'flask.scaffold'
Currently, I have two questions: How should this problem be solved? The teacher's solution is to run the following four lines of code to generate a new conda environment and try again, right? conda create -n gee2 python conda activate gee2 conda install -c conda-forge mamba mamba install -c conda-forge localtileserver geemap
I hope the teacher can answer my question the most: Teacher, I have read and purchased the books you published on CSDN, and heard about the courses you taught at East China Normal University in Shanghai. You all said that running these four lines of code can use all the functions of Geemap: conda create -n gee python conda activate gee conda install -c conda-forge mamba mamba install -c conda-forge geemap pygis
But now is it necessary to change the last line to mamba install - c conda forge localtileserver geemap
What should I do if I want to use this addraster function in the Gee environment generated by the following four lines of code? Or is it necessary to reinstall a new environment? conda create -n gee python conda activate gee conda install -c conda-forge mamba mamba install -c conda-forge geemap pygis
Description
I want to visualize my scene image
What I Did
Code error
'''
ImportError Traceback (most recent call last) File D:\software\anaconda\envs\gee\Lib\site-packages\flask_restx\api.py:18 17 try: ---> 18 from flask.helpers import _endpoint_from_view_func 19 except ImportError:
ImportError: cannot import name '_endpoint_from_view_func' from 'flask.helpers' (D:\software\anaconda\envs\gee\Lib\site-packages\flask\helpers.py)
During handling of the above exception, another exception occurred:
ModuleNotFoundError Traceback (most recent call last) File D:\software\anaconda\envs\gee\Lib\site-packages\geemap\common.py:1839, in check_package(name, URL) 1838 try: -> 1839 import(name.lower()) 1840 except Exception:
File D:\software\anaconda\envs\gee\Lib\site-packages\localtileserver__init__.py:3 2 from localtileserver._version import version ----> 3 from localtileserver.client import TileClient, get_or_create_tile_client 4 from localtileserver.helpers import hillshade, parse_shapely, polygon_to_geojson, save_new_raster
File D:\software\anaconda\envs\gee\Lib\site-packages\localtileserver\client.py:22 21 from localtileserver.configure import get_default_client_params ---> 22 from localtileserver.manager import AppManager 23 from localtileserver.tiler import ( 24 format_to_encoding, 25 get_building_docs, (...) 32 palette_valid_or_raise, 33 )
File D:\software\anaconda\envs\gee\Lib\site-packages\localtileserver\manager.py:1 ----> 1 from localtileserver.web import create_app 4 class AppManager:
File D:\software\anaconda\envs\gee\Lib\site-packages\localtileserver\web__init__.py:2 1 # flake8: noqa: F401 ----> 2 from localtileserver.web import rest, urls, views 3 from localtileserver.web.application import create_app, run_app
File D:\software\anaconda\envs\gee\Lib\site-packages\localtileserver\web\rest.py:4 3 from flask import request, send_file ----> 4 from flask_restx import Api, Resource as View 5 from rasterio import RasterioIOError
File D:\software\anaconda\envs\gee\Lib\site-packages\flask_restx__init__.py:2 1 from . import fields, reqparse, apidoc, inputs, cors ----> 2 from .api import Api # noqa 3 from .marshalling import marshal, marshal_with, marshal_with_field # noqa
File D:\software\anaconda\envs\gee\Lib\site-packages\flask_restx\api.py:20 19 except ImportError: ---> 20 from flask.scaffold import _endpoint_from_view_func 21 from flask.signals import got_request_exception
ModuleNotFoundError: No module named 'flask.scaffold'
During handling of the above exception, another exception occurred:
ImportError Traceback (most recent call last) Cell In[3], line 8 5 vis_params = {'min': 0, 'max': 1, 'palette': ['green', 'blue']} 7 # 添加本地栅格影像到地图上 ----> 8 Map.add_raster(filename, vis_params=vis_params, layer_name='Local Image') 10 # 添加颜色条到地图 11 Map.add_colorbar(vis_params, label='Value')
File D:\software\anaconda\envs\gee\Lib\site-packages\geemap\geemap.py:2404, in Map.add_raster(self, source, indexes, colormap, vmin, vmax, nodata, attribution, layer_name, zoom_to_layer, visible, array_args, kwargs) 2401 if isinstance(source, np.ndarray) or isinstance(source, xr.DataArray): 2402 source = array_to_image(source, array_args) -> 2404 tile_layer, tile_client = get_local_tile_layer( 2405 source, 2406 indexes=indexes, 2407 colormap=colormap, 2408 vmin=vmin, 2409 vmax=vmax, 2410 nodata=nodata, 2411 attribution=attribution, 2412 layer_name=layer_name, 2413 return_client=True, 2414 **kwargs, 2415 ) 2416 tile_layer.visible = visible 2418 self.add(tile_layer)
File D:\software\anaconda\envs\gee\Lib\site-packages\geemap\common.py:10788, in get_local_tile_layer(source, port, debug, indexes, colormap, vmin, vmax, nodata, attribution, tile_format, layer_name, return_client, quiet, **kwargs) 10761 """Generate an ipyleaflet/folium TileLayer from a local raster dataset or remote Cloud Optimized GeoTIFF (COG). 10762 If you are using this function in JupyterHub on a remote server and the raster does not render properly, try 10763 running the following two lines before calling this function: (...) 10784 ipyleaflet.TileLayer | folium.TileLayer: An ipyleaflet.TileLayer or folium.TileLayer. 10785 """ 10786 import rasterio
File D:\software\anaconda\envs\gee\Lib\site-packages\geemap\common.py:1841, in check_package(name, URL) 1839 import(name.lower()) 1840 except Exception: -> 1841 raise ImportError( 1842 f"{name} is not installed. Please install it before proceeding. {URL}" 1843 )
ImportError: localtileserver is not installed. Please install it before proceeding. https://github.com/banesullivan/localtileserver
'''