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

Kaleido executable not found (on Windows 10) #61

Closed
MSeifert04 opened this issue Dec 7, 2020 · 9 comments
Closed

Kaleido executable not found (on Windows 10) #61

MSeifert04 opened this issue Dec 7, 2020 · 9 comments
Labels
bug something broken
Milestone

Comments

@MSeifert04
Copy link

I just installed kaleido 0.1.0 and plotly (python 3.9, newest pip inside a virtualenv on Windows 10) and the first attempt failed:

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-2f> in <module>
     24 
     25 fig.show()
---> 26 fig.write_image(r"fig1.png")

...venv3.9\lib\site-packages\plotly\basedatatypes.py in write_image(self, *args, **kwargs)
   3804         import plotly.io as pio
   3805 
-> 3806         return pio.write_image(self, *args, **kwargs)
   3807 
   3808     # Static helpers

...venv3.9\lib\site-packages\plotly\io\_kaleido.py in write_image(fig, file, format, scale, width, height, validate, engine)
    243     # -------------
    244     # Do this first so we don't create a file if image conversion fails
--> 245     img_data = to_image(
    246         fig,
    247         format=format,

...venv3.9\lib\site-packages\plotly\io\_kaleido.py in to_image(fig, format, width, height, scale, validate, engine)
    129     # ---------------
    130     fig_dict = validate_coerce_fig_to_dict(fig, validate)
--> 131     img_bytes = scope.transform(
    132         fig_dict, format=format, width=width, height=height, scale=scale
    133     )

...venv3.9\lib\site-packages\kaleido\scopes\plotly.py in transform(self, figure, format, width, height, scale)
    101         # Transform in using _perform_transform rather than superclass so we can access the full
    102         # response dict, including error codes.
--> 103         response = self._perform_transform(
    104             figure, format=format, width=width, height=height, scale=scale
    105         )

...venv3.9\lib\site-packages\kaleido\scopes\base.py in _perform_transform(self, data, **kwargs)
    278         """
    279         # Ensure that kaleido subprocess is running
--> 280         self._ensure_kaleido()
    281 
    282         # Perform export

....venv3.9\lib\site-packages\kaleido\scopes\base.py in _ensure_kaleido(self)
    164                     # spaces.  The subprocess.Popen docs makes it sound like this shouldn't be
    165                     # necessary.
--> 166                     proc_args = self._build_proc_args()
    167                     self._proc = subprocess.Popen(
    168                         proc_args,

....venv3.9\lib\site-packages\kaleido\scopes\base.py in _build_proc_args(self)
    111         :return: list of flags
    112         """
--> 113         proc_args = [self.executable_path(), self.scope_name]
    114         for k in self._scope_flags:
    115             v = getattr(self, k)

...venv3.9\lib\site-packages\kaleido\scopes\base.py in executable_path(cls)
     87                 path = os.environ.get("PATH", os.defpath)
     88                 formatted_path = path.replace(os.pathsep, "\n    ")
---> 89                 raise ValueError(
     90                     """
     91 The kaleido executable is required by the kaleido Python library, but it was not included

ValueError: 
The kaleido executable is required by the kaleido Python library, but it was not included
in the Python package and it could not be found on the system PATH.

Searched for included kaleido executable at:
    ...venv3.9\lib\site-packages\kaleido\executable\kaleido

The interesting bit is that the executable is almost there (IPython debugger):

ipdb>  vendored_executable_path
'...venv3.9\\lib\\site-packages\\kaleido\\executable\\kaleido'
ipdb>  os.path.exists(vendored_executable_path)
False
ipdb>  os.path.exists('...venv3.9\\lib\\site-packages\\kaleido\\executable\\bin')
True
ipdb>  os.path.exists('...venv3.9\\lib\\site-packages\\kaleido\\executable\\kaleido.cmd')
True
ipdb>  os.path.exists('...venv3.9\\lib\\site-packages\\kaleido\\executable\\bin\\kaleido.exe')
True
ipdb>  exit
...venv3.9\Lib\site-packages\kaleido\executable> tree . /f
...VENV3.9\LIB\SITE-PACKAGES\KALEIDO\EXECUTABLE
│   CREDITS.html
│   kaleido.cmd
│   LICENSE.txt
│   version
│
├───bin
│   │   chrome_debug.log
│   │   debug.log
│   │   icudtl.dat
│   │   kaleido.exe
│   │   settings.dat
│   │
│   ├───locales
│   ├───reports
│   └───swiftshader
│           libEGL.dll
│           libEGL.dll.lib
│           libEGL.dll.pdb
│           libGLESv2.dll
│           libGLESv2.dll.lib
│           libGLESv2.dll.pdb
│
└───js
        kaleido_scopes.js

I'm not sure if I did something wrong and I hope I included sufficient information so this issue is useful. Please let me know if I need to amend something.

@MSeifert04 MSeifert04 changed the title Kaleido executable (on Windows 10) Kaleido executable not found (on Windows 10) Dec 7, 2020
@jonmmease
Copy link
Collaborator

Thanks for the report @MSeifert04. Have you tried older versions of kaleido in Python 3.9? Have you tried with an older version of Python?

I'll do some experiments, but looks like it might have something to do with how the .cmd extension is treated when checking for file existence.

@jonmmease jonmmease added the bug something broken label Dec 7, 2020
@jonmmease
Copy link
Collaborator

Never mind, I can reproduce it. FWIW, this only affects pip packages on Windows in kaleido version 0.1.0.

Other operating systems, and Windows installed from conda-forge using conda are ok.

Workaround

Here's a workaround until we get a fix out. If you add kaleido's executable directory to your PATH, it will find it.

import os
os.environ["PATH"] = os.environ["PATH"] + ";...venv3.9\\lib\\site-packages\\kaleido\\executable\\"

@MSeifert04
Copy link
Author

@jonmmease Thank you for digging into the issue. I tried both the workaround and the commit e05d089 and, indeed, both do solve the error on my machine.

Thank you very much! 👍

@jonmmease
Copy link
Collaborator

Fixed in e05d089 and released on PyPI as version 0.1.0.post1.

Thanks again for letting us know!

Note: 0.1.0.post1 was only released only for Windows pip packages, as no other operating systems or package formats were affected.

@jonmmease jonmmease added this to the 0.1.0.post1 milestone Dec 8, 2020
@mgroth0
Copy link

mgroth0 commented Mar 24, 2021

I'm having this problem on Mac, python 3.9

@mgroth0
Copy link

mgroth0 commented Mar 24, 2021

I tried os.environ["PATH"] = "/Users/matt/miniconda3/envs/dnn39/bin/". This actually had an effect, but only lead to a different error:
Screen Shot 2021-03-23 at 8 38 11 PM

@jonmmease
Copy link
Collaborator

Hi @mgroth0, thanks for the info. Have you tried any older Python versions?

@jonmmease
Copy link
Collaborator

@TheMadMoose
Copy link

Had the same problem on Windows 11. I initially followed numerous comments recommending installing version 0.1.0. That solved my initial problem (hanging), but introduced the “executable not located” issue mentioned here.

I then went version by version (of Kaleido) starting from the latest and made it work without any adjustments on version 0.1.0.post1.

Sorry, if my comment is improper (please let me know! I'm not too sure what's okay to do here and what not, haha).
Figured it might help someone else in a similar boat.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something broken
Projects
None yet
Development

No branches or pull requests

4 participants