Skip to content

Issue with documentation regarding python requirements #2175

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

Closed
mmahmoudian opened this issue Aug 24, 2022 · 1 comment · Fixed by #2360
Closed

Issue with documentation regarding python requirements #2175

mmahmoudian opened this issue Aug 24, 2022 · 1 comment · Fixed by #2360

Comments

@mmahmoudian
Copy link

mmahmoudian commented Aug 24, 2022

The issue in one sentence

Documentation and error messages are badly misleading.

Elaboration on the issue

In the documentation, especially ?plotly::save_image, there is extra and unnecessary focus on miniconda, and also on all the error messages of plotly::save_image(). This is despite the fact that python is practically pre-installed on all Linux distros and almost all macOS setups.

Additionally, there are two related issues:

  1. deprecated functions send user to a rabbit-hole rather than pointing them to the function they should use (export() -> orca() -> kaleido() -> Deadend, but ?kaleido -> save_image())
  2. the save_image() does not check availability of all the python modules and dependencies and the user has to go through a step-wise process of getting error, installing the next missing one and etc.

In the following, I have showed the reasoning and the journey I went through to get this working:


For the following, I have used the verbatim code from here:
https://plotly.com/r/violin/#split-violin-plot#advanced-violin-plot

  1. Following some online tutorial I figured I can use:
plotly::export(p = fig, file = "aa.svg")
Error: Must provide an object of class 'rsClientServer' to the `selenium` argument to export this plot (see examples section on `help(export)`)
In addition: Warning messages:
1: 'plotly::export' is deprecated.
Use 'orca' instead.
See help("Deprecated") 
  1. Ah, deprecated. So let's try orca():
plotly::orca(p = fig, file = "aa.svg")
Error: The orca command-line utility is required for this functionality.

Please follow the installation instructions here -- https://github.com/plotly/orca#installation
In addition: Warning message:
'plotly::orca' is deprecated.
Use 'kaleido' instead.
See help("Deprecated") 
  1. Oh, deprecated too! let's see how the kaleido should be used. Well, ?kaleido shows that the save_image() should be used, so let's see
plotly::save_image(p = fig, file = "aa.svg")
No non-system installation of Python could be found.
Would you like to download and install Miniconda?
Miniconda is an open source environment management system for Python.
See https://docs.conda.io/en/latest/miniconda.html for more details.

Would you like to install Miniconda? [Y/n]: n
Installation aborted.
Error in py_module_import(module, convert = convert) : 
  ModuleNotFoundError: No module named 'kaleido'

The python is already there, so the error "No non-system installation of Python could be found." is nonsensical:

python --version
Python 3.10.5which python 
/usr/bin/pythonls -alh $(which python)
lrwxrwxrwx 1 root root 7 Aug  1 10:53 /usr/bin/python -> python3

This is a bad situation and it took me a while to understand what the issue is: lack of the reticulate R package so that R can talk to python. I wonder why this is not a dependency of the plotly R package!

install.packages("reticulate")
  1. Now that R can talk with python (again, minoconda is NOT NEEDED), let's try again:
plotly::save_image(p = fig, file = "aa.svg")
Error in py_module_import(module, convert = convert) : 
  ModuleNotFoundError: No module named 'kaleido'

The error is clear, but not user-friendly because it does not clarify to user that this is a python thing (apart from py_ in the function name). Regardless, I installed it:

pip install kaleido
  1. Try again...
plotly::save_image(p = fig, file = "graph 1.svg")
Error in py_run_string_impl(code, local, convert) : 
  ModuleNotFoundError: No module named 'plotly'

Same user-friendliness complaint as above.

pip install plotly
  1. Now it works!

System info

  • plotly 4.10.0 2021-10-09 CRAN (R 4.1.0)
  • reticulate 1.25 2022-05-11 [1] CRAN (R 4.1.2)
  • R version 4.1.2 (2021-11-01)
  • rstudio 2022.02.2+485 Prairie Trillium (server)
  • OS: Manjaro Linux

Please let me know if you need further information

@serkor1
Copy link

serkor1 commented Apr 17, 2024

Running on Ubuntu 22.04 - followed all your steps. I am still not past the error-message:

Error in py_module_import(module, convert = convert) : 
  ModuleNotFoundError: No module named 'kaleido'

I miss the webshot()-wrapper plotly::export()-function to be honest.

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

Successfully merging a pull request may close this issue.

2 participants