python - Kaleido RuntimeError - Stack Overflow

I create a virtual environment usingpython3 -m venv venvActivatesource venvbinactivateInstall Plotly p

  1. I create a virtual environment using
python3 -m venv venv
  1. Activate
source venv/bin/activate
  1. Install Plotly package
pip install plotly
  1. Try to run the following script dft.py
#!./venv/bin/python3
from math import pi

from plotly.graph_objects import Figure, Scatter
from plotly.io import full_figure_for_development as ffdf

dr: int = 1000
dv: list[float] = [2.0*pi*i/dr for i in range(dr + 1)]


# plot the result
fig = Figure()
fig.add_trace(Scatter(x=dv, y=dv))

# save the figure
ffdf(fig, warn=False)
fig.write_image('a.pdf', engine="kaleido")

  1. An error appears
Traceback (most recent call last):
  File "/home/r/ma/fa/./dft.py", line 20, in <module>
    ffdf(fig, warn=False)
  File "/home/r/ma/fa/venv/lib/python3.12/site-packages/plotly/io/_kaleido.py", line 327, in full_figure_for_development
    raise ValueError(
ValueError: 
Full figure generation requires the kaleido package,
which can be installed using pip:
    $ pip install -U kaleido
  1. Install kaleido
pip install -U kaleido
  1. When I am trying to execute the script I get the following error
Traceback (most recent call last):
  File "/home/r/ma/fa/./dft.py", line 6, in <module>
    from plotly.io import full_figure_for_development as ffdf
  File "<frozen importlib._bootstrap>", line 1412, in _handle_fromlist
  File "/home/r/ma/fa/venv/lib/python3.12/site-packages/_plotly_utils/importers.py", line 36, in __getattr__
    class_module = importlib.import_module(rel_module, parent_name)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/importlib/__init__.py", line 90, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/r/ma/fa/venv/lib/python3.12/site-packages/plotly/io/_kaleido.py", line 10, in <module>
    scope = PlotlyScope()
            ^^^^^^^^^^^^^
  File "/home/r/ma/fa/venv/lib/python3.12/site-packages/kaleido/scopes/plotly.py", line 63, in __init__
    raise RuntimeError("Kaleido now requires that chrome/chromium is installed separately. Kaleido will try to detect it automatically, but the environmental error \"BROWSER_PATH\" can also be set")
RuntimeError: Kaleido now requires that chrome/chromium is installed separately. Kaleido will try to detect it automatically, but the environmental error "BROWSER_PATH" can also be set

I was using this scheme to draw charts many times in last years, everything was fine. According to the release history of the Kaleido package pypi, Kaleido has been upgraded yesterday to version 0.4.2.

What is chrome/chromium? There is no such package on PyPi. Do anyone has an idea how to fix the error?

  1. I create a virtual environment using
python3 -m venv venv
  1. Activate
source venv/bin/activate
  1. Install Plotly package
pip install plotly
  1. Try to run the following script dft.py
#!./venv/bin/python3
from math import pi

from plotly.graph_objects import Figure, Scatter
from plotly.io import full_figure_for_development as ffdf

dr: int = 1000
dv: list[float] = [2.0*pi*i/dr for i in range(dr + 1)]


# plot the result
fig = Figure()
fig.add_trace(Scatter(x=dv, y=dv))

# save the figure
ffdf(fig, warn=False)
fig.write_image('a.pdf', engine="kaleido")

  1. An error appears
Traceback (most recent call last):
  File "/home/r/ma/fa/./dft.py", line 20, in <module>
    ffdf(fig, warn=False)
  File "/home/r/ma/fa/venv/lib/python3.12/site-packages/plotly/io/_kaleido.py", line 327, in full_figure_for_development
    raise ValueError(
ValueError: 
Full figure generation requires the kaleido package,
which can be installed using pip:
    $ pip install -U kaleido
  1. Install kaleido
pip install -U kaleido
  1. When I am trying to execute the script I get the following error
Traceback (most recent call last):
  File "/home/r/ma/fa/./dft.py", line 6, in <module>
    from plotly.io import full_figure_for_development as ffdf
  File "<frozen importlib._bootstrap>", line 1412, in _handle_fromlist
  File "/home/r/ma/fa/venv/lib/python3.12/site-packages/_plotly_utils/importers.py", line 36, in __getattr__
    class_module = importlib.import_module(rel_module, parent_name)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/importlib/__init__.py", line 90, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/r/ma/fa/venv/lib/python3.12/site-packages/plotly/io/_kaleido.py", line 10, in <module>
    scope = PlotlyScope()
            ^^^^^^^^^^^^^
  File "/home/r/ma/fa/venv/lib/python3.12/site-packages/kaleido/scopes/plotly.py", line 63, in __init__
    raise RuntimeError("Kaleido now requires that chrome/chromium is installed separately. Kaleido will try to detect it automatically, but the environmental error \"BROWSER_PATH\" can also be set")
RuntimeError: Kaleido now requires that chrome/chromium is installed separately. Kaleido will try to detect it automatically, but the environmental error "BROWSER_PATH" can also be set

I was using this scheme to draw charts many times in last years, everything was fine. According to the release history of the Kaleido package pypi., Kaleido has been upgraded yesterday to version 0.4.2.

What is chrome/chromium? There is no such package on PyPi. Do anyone has an idea how to fix the error?

Share Improve this question asked Nov 19, 2024 at 17:22 ResistorSmokerResistorSmoker 598 bronze badges 4
  • Which web browser do you have installed? You can't find Chrome/chromium on pypi because they're web browsers, not python packages. Chrome is referring to the specific Google Chrome browser. As for chromium, I'm not sure if they specifically want the Chromium Browser or one of the many that are based on it. – kevin41 Commented Nov 19, 2024 at 19:14
  • @kevin41 Yandex. I was using this browser before the error occured, never have Chrome installed. – ResistorSmoker Commented Nov 19, 2024 at 23:04
  • @kevin41 btw I installed an older version of kaleido pip install 'kaleido==0.2.1' --force-reinstall and everything works fine, however the problem remains open – ResistorSmoker Commented Nov 19, 2024 at 23:15
  • 1 The latest version of Kaleido requires the chrome browser to be installed. See this [article}(plotly/blog/kaleido-the-next-generation) for more information. – r-beginners Commented Nov 20, 2024 at 2:34
Add a comment  | 

2 Answers 2

Reset to default 1

chrome/chromium is the Google Chrome internet browser. However, instead of installing it, I would recommend just downgrading to an older version of Kaleido, and avoid these issues. You can run the following command to downgrade Kaleido to a version that does not require that chrome/chromium be installed:

pip install --upgrade "kaleido==0.1.*"

For reference: pip install --upgrade allows you to change the version of a package, you can supply it with a version number which is lower than the one you have installed, and it will 'upgrade' it to the older version.

I had the same error as you suggested, I forced the previous version.

In the Release history [https://pypi./project/kaleido/#history][1] you can see the they YANKED the release for too many breaking changes.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742410310a4438678.html

相关推荐

  • python - Kaleido RuntimeError - Stack Overflow

    I create a virtual environment usingpython3 -m venv venvActivatesource venvbinactivateInstall Plotly p

    4小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信