plotly / Kaleido

Fast static image export for web-based visualization libraries with zero dependencies
Other
349 stars 33 forks source link

Add double quotes to launcher scripts to support environments with spaces #85

Open sumit-subedi opened 3 years ago

sumit-subedi commented 3 years ago

I have seen multiple issues regarding this but not same with mine. I get error every time I try to invoke write_image():

ValueError: Failed to start Kaleido subprocess. Error stream:

<my location>/env/lib/python3.8/site-packages/kaleido/executable/kaleido: line 9: cd: too many arguments <my location>/env/lib/python3.8/site-packages/kaleido/executable/kaleido: line 10: ./bin/kaleido: No such file or directory

Can anyone help me with this issue?

jonmmease commented 3 years ago

Hi @sumit-subedi, thanks for letting us know.

Do you happen to have a space in the path of your environment?

I think we may need to add better handling of spaces in paths in the kaleido bash file. If so, could you try either:

sumit-subedi commented 3 years ago

Thanks @jonmmease . This solved my issue.

jonmmease commented 3 years ago

Great! BTW, I changed the issue title to reflect what we need to do fix this in kaleido itself.

cainmagi commented 8 months ago

I am quite sure that this issue is not solved on Windows. Because when Kaleido is installed on windows, its executable file is not directly called by Python.subprocess, the routine is like this:

flowchart TD
  subproc[Python.subprocess]
  cmd1[Library\bin\kaleido.cmd]
  cmd2[Library\bin\KaleidoApp\kaleido.cmd]
  exe[Library\bin\KaleidoApp\bin\kaleido.exe]
  subproc --> cmd1 --> cmd2 --> exe

There is a significant issue in Library\bin\kaleido.cmd. When the installation path (for example, the user folder name) contains a space character , I need to modify this script like this:

@echo off
-C:/Users/User name/.conda/envs/env-name\Library\bin\KaleidoApp/kaleido.cmd %*
+"C:/Users/User name/.conda/envs/env-name\Library\bin\KaleidoApp/kaleido.cmd" %*

Tested on:

Windows 11, 23H2 python 3.8.17 plotly==5.15.0 kaleido>=0.2.0rc1,<=0.2.1

surajgattani commented 3 months ago

This issue still persists in the library and seems like a simple fix but hasn't been added yet Can we please fix it in the next version?

Bengt commented 5 days ago

I can confirm that replacing the content of venv/lib/python3.12/site-packages/kaleido/executable with the following resolves this issue about spaces in the path name for me under Ubuntu Linux:

#!/bin/bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"

export LD_LIBRARY_PATH=$DIR/lib:$LD_LIBRARY_PATH
export FONTCONFIG_PATH=$DIR/etc/fonts
export XDG_DATA_HOME=$DIR/xdg
unset LD_PRELOAD

cd "$DIR"
./bin/kaleido $@