plotly / Kaleido

Fast static image export for web-based visualization libraries with zero dependencies
MIT License
378 stars 38 forks source link

Error with Pyinstaller .exe file (Windows 10) #39

Closed drdeleon closed 4 years ago

drdeleon commented 4 years ago

While trying to use Plotly and Kaleido (0.0.3.post1) in a Pyinstaller .exe file (Windows 10) I got this error:

`File "kaleido\scopes\plotly.py", line 103, in transform File "kaleido\scopes\base.py", line 201, in _perform_transform File "kaleido\scopes\base.py", line 120, in _ensure_kaleido ValueError: Failed to start Kaleido subprocess. Error stream:

The system cannot find the path specified.`

While doing some research I found out that Pyinstaller has problems with subprocesses and some things should be changed for it to work in Windows .exe files (https://github.com/pyinstaller/pyinstaller/wiki/Recipe-subprocess). I'm not sure if I should change something with my Pyinstaller configuration in order to fix the problem or the subprocess code would fix it for Windows. I would appreciate any help (Kaleido is relatively new so I'm not sure how to proceed and there isn't much info).

jonmmease commented 4 years ago

Hi @DouglasDL28, thanks for the report.

Would you be willing to create a minimal PyInstaller example that produces this error? We don't have much experience using PyInstaller, so there's a much better chance of someone taking a look if we have this as a starting point. Might be easiest to do this in a small standalone repo, including a README for how to package it, and link it here.

Thanks!

drdeleon commented 4 years ago

Hi @jonmmease.

While doing the repo for the testing I came across various problems with both Plotly and Kaleido with Pyinstaller again. I found a solution for the Plotly errors online and it occurred to me that maybe the same solution would apply to Kaleido, and it did! For it to work you just need to use the --add-data "c:\users\username\appdata\local\programs\python\python37\lib\site-packages\kaleido\;kaleido".

jonmmease commented 4 years ago

Glad you got things working! I'm assuming --add-data is a PyInstaller option? It does make sense that this directory would be needed. Are you aware of anything that could be done in the Kaleido Python package itself to help PyInstaller figure this out automatically?

drdeleon commented 4 years ago

Yes, forgot to mention add-data is a PyInstaller option. I'm sorry but I don't know what can be done to make it work without additional configuration on PyInstaller. The whole purpose of Pyinstaller is to be compatible with 3rd-party packages out-of-the-box, but it is not rare to use additional configuration to make it work. Thanks for the help!

jonmmease commented 4 years ago

Alright, going to close this issue for now then. Thanks again for updating the issue with your solution!