-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Choropleth_mapbox and FigureWidget - 'mapbox._derived' Value Error #2570
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
Comments
Added a temporary hack in
|
Hello! |
When editing
Before the error is raised, create a conditional check that skips that error if |
Hello, just to note that I also have the same issue with a scatter mapbox plot. Using add_scattermapbox does not seem to help. Here is a minimal reproducer:
|
I have the same issue. |
I have the same issue too. |
Just run this to do @macadology 's edit. basedatatypesPath = os.path.join(os.path.dirname(os.__file__),'site-packages','plotly','basedatatypes.py')
# read basedatatypes.py
with open(basedatatypesPath, 'r') as f:
lines = f.read()
find = 'if not BaseFigure._is_key_path_compatible(key_path_str, self.layout):'
replace = """if not BaseFigure._is_key_path_compatible(key_path_str, self.layout):
if key_path_str == "mapbox._derived":
return"""
# add new text
lines = lines.replace(find,replace)
# overwrite old 'basedatatypes.py'
with open(basedatatypesPath, 'w') as f:
f.write(lines) |
I'm also having the same issue. Are there any updates on when this will be addressed? |
Just bumping this. Seeing the same behavior for @cjroberts min example. |
No one on our development team has ever been able to reproduce this behaviour starting from a clean environment, so we don't know what to recommend. If someone can provide reproducible instructions for replicating this behaviour, I can investigate further. Some folks have reportedly achieved success by un/re-installing |
Yay, glad to hear back from the development team. I tried it again from a clean environment too and I encountered the same error. See below for my setup using conda and pip. For convenience, I didn't specify a particular version but instead rely on pip to resolve the latest version. conda create -n myenv python=3.9
conda activate myenv
pip install plotly
pip install pandas
pip install ipython
pip install ipywidgets
pip install jupyter
pip install notebook When running the min code in a jupyter notebook environment, the error message appears whenever I interact with the plot. Below is a screenshot of the actual error. Is it possible the development team tested the code outside of the notebook environment? Let me know if I should create a mybinder notebook to reproduce the error. |
Thanks for this. Yes, a replicable environment like Binder would be a great help :) |
Here you go. Once the plot is generated, moving it or interacting with it will cause error messages to appear in the output cell below the plot. |
Run the following function as a temporary fix. def fix_widget_error():
"""
Fix FigureWidget - 'mapbox._derived' Value Error.
Adopted from: https://github.com/plotly/plotly.py/issues/2570#issuecomment-738735816
"""
import shutil
import pkg_resources
pkg_dir = os.path.dirname(pkg_resources.resource_filename("plotly", "plotly.py"))
basedatatypesPath = os.path.join(pkg_dir, "basedatatypes.py")
backup_file = basedatatypesPath.replace(".py", "_bk.py")
shutil.copyfile(basedatatypesPath, backup_file)
# read basedatatypes.py
with open(basedatatypesPath, "r") as f:
lines = f.read()
find = "if not BaseFigure._is_key_path_compatible(key_path_str, self.layout):"
replace = """if not BaseFigure._is_key_path_compatible(key_path_str, self.layout):
if key_path_str == "mapbox._derived":
return"""
# add new text
lines = lines.replace(find, replace)
# overwrite old 'basedatatypes.py'
with open(basedatatypesPath, "w") as f:
f.write(lines) |
@giswqs unfortunately I cannot... the environment I am using does not permit writing to site-packages |
@janhurst Sorry to hear that! This issue has been open for 2.5 years now. I have been waiting for an official fix. Not sure when it will happen. |
I am seeing the same problem with:
|
This still seems to a problem. It is now July, 2024. Is the above workaround still the recommended way to deal with this problem? |
@archmoj will your recent work with MapLibre address this? |
When plotting a choropleth_mapbox using plotly express and containing it within a figure widget, I am encountering a ValueError when I drag the plot around. The error does not affect the interactivity of the plot, but it does create a huge error log in the output. I thought about trying go.add_choroplethmapbox(), but realized that the arguments are different from the plotly express version.
I have included a sample code below.
Plotly [offline]
jupyter core : 4.6.3
jupyter-notebook : 6.0.3
ipywidgets : 7.5.1
traitlets : 4.3.3
plotly : 4.8.1
The text was updated successfully, but these errors were encountered: