plotly / Kaleido

Fast static image export for web-based visualization libraries with zero dependencies

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

static export from R not working

Adafede opened this issue · comments

Hi,

Looks like there is a little something not working but couldn't figure out what:

reticulate::install_miniconda(force = TRUE)
reticulate::conda_install('r-reticulate', 'python-kaleido')
reticulate::conda_install('r-reticulate', 'plotly', channel = 'plotly')
reticulate::use_miniconda('r-reticulate')
p <- plotly::plot_ly(x = 1:10)
plotly::save_image(p, "test.pdf")
sessionInfo()

gives

> reticulate::install_miniconda(force = TRUE)
* Installing Miniconda -- please wait a moment ...
* Downloading 'https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-x86_64.sh' ...
trying URL 'https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-x86_64.sh'
Content type 'application/x-sh' length 57904526 bytes (55.2 MB)
==================================================
downloaded 55.2 MB

PREFIX=/Users/rutza/Library/r-miniconda
Unpacking payload ...
Collecting package metadata (current_repodata.json): ...working... done                                        
Solving environment: ...working... done

## Package Plan ##

  environment location: /Users/rutza/Library/r-miniconda

  added / updated specs:
    - brotlipy==0.7.0=py39h9ed2024_1003
    - ca-certificates==2021.10.26=hecd8cb5_2
    - certifi==2021.10.8=py39hecd8cb5_2
    - cffi==1.15.0=py39hc55c11b_1
    - charset-normalizer==2.0.4=pyhd3eb1b0_0
    - conda-content-trust==0.1.1=pyhd3eb1b0_0
    - conda-package-handling==1.7.3=py39h9ed2024_1
    - conda==4.11.0=py39hecd8cb5_0
    - cryptography==36.0.0=py39hf6deb26_0
    - idna==3.3=pyhd3eb1b0_0
    - libcxx==12.0.0=h2f01273_0
    - libffi==3.3=hb1e8313_2
    - ncurses==6.3=hca72f7f_2
    - openssl==1.1.1m=hca72f7f_0
    - pip==21.2.4=py39hecd8cb5_0
    - pycosat==0.6.3=py39h9ed2024_0
    - pycparser==2.21=pyhd3eb1b0_0
    - pyopenssl==21.0.0=pyhd3eb1b0_1
    - pysocks==1.7.1=py39hecd8cb5_0
    - python.app==3=py39hca72f7f_0
    - python==3.9.7=h88f2d9e_1
    - readline==8.1.2=hca72f7f_1
    - requests==2.27.1=pyhd3eb1b0_0
    - ruamel_yaml==0.15.100=py39h9ed2024_0
    - setuptools==58.0.4=py39hecd8cb5_0
    - six==1.16.0=pyhd3eb1b0_0
    - sqlite==3.37.0=h707629a_0
    - tk==8.6.11=h7bc2e8c_0
    - tqdm==4.62.3=pyhd3eb1b0_1
    - tzdata==2021e=hda174b7_0
    - urllib3==1.26.7=pyhd3eb1b0_0
    - wheel==0.37.1=pyhd3eb1b0_0
    - xz==5.2.5=h1de35cc_0
    - yaml==0.2.5=haf1e3a3_0
    - zlib==1.2.11=h4dc903c_4


The following NEW packages will be INSTALLED:

  brotlipy           pkgs/main/osx-64::brotlipy-0.7.0-py39h9ed2024_1003
  ca-certificates    pkgs/main/osx-64::ca-certificates-2021.10.26-hecd8cb5_2
  certifi            pkgs/main/osx-64::certifi-2021.10.8-py39hecd8cb5_2
  cffi               pkgs/main/osx-64::cffi-1.15.0-py39hc55c11b_1
  charset-normalizer pkgs/main/noarch::charset-normalizer-2.0.4-pyhd3eb1b0_0
  conda              pkgs/main/osx-64::conda-4.11.0-py39hecd8cb5_0
  conda-content-tru~ pkgs/main/noarch::conda-content-trust-0.1.1-pyhd3eb1b0_0
  conda-package-han~ pkgs/main/osx-64::conda-package-handling-1.7.3-py39h9ed2024_1
  cryptography       pkgs/main/osx-64::cryptography-36.0.0-py39hf6deb26_0
  idna               pkgs/main/noarch::idna-3.3-pyhd3eb1b0_0
  libcxx             pkgs/main/osx-64::libcxx-12.0.0-h2f01273_0
  libffi             pkgs/main/osx-64::libffi-3.3-hb1e8313_2
  ncurses            pkgs/main/osx-64::ncurses-6.3-hca72f7f_2
  openssl            pkgs/main/osx-64::openssl-1.1.1m-hca72f7f_0
  pip                pkgs/main/osx-64::pip-21.2.4-py39hecd8cb5_0
  pycosat            pkgs/main/osx-64::pycosat-0.6.3-py39h9ed2024_0
  pycparser          pkgs/main/noarch::pycparser-2.21-pyhd3eb1b0_0
  pyopenssl          pkgs/main/noarch::pyopenssl-21.0.0-pyhd3eb1b0_1
  pysocks            pkgs/main/osx-64::pysocks-1.7.1-py39hecd8cb5_0
  python             pkgs/main/osx-64::python-3.9.7-h88f2d9e_1
  python.app         pkgs/main/osx-64::python.app-3-py39hca72f7f_0
  readline           pkgs/main/osx-64::readline-8.1.2-hca72f7f_1
  requests           pkgs/main/noarch::requests-2.27.1-pyhd3eb1b0_0
  ruamel_yaml        pkgs/main/osx-64::ruamel_yaml-0.15.100-py39h9ed2024_0
  setuptools         pkgs/main/osx-64::setuptools-58.0.4-py39hecd8cb5_0
  six                pkgs/main/noarch::six-1.16.0-pyhd3eb1b0_0
  sqlite             pkgs/main/osx-64::sqlite-3.37.0-h707629a_0
  tk                 pkgs/main/osx-64::tk-8.6.11-h7bc2e8c_0
  tqdm               pkgs/main/noarch::tqdm-4.62.3-pyhd3eb1b0_1
  tzdata             pkgs/main/noarch::tzdata-2021e-hda174b7_0
  urllib3            pkgs/main/noarch::urllib3-1.26.7-pyhd3eb1b0_0
  wheel              pkgs/main/noarch::wheel-0.37.1-pyhd3eb1b0_0
  xz                 pkgs/main/osx-64::xz-5.2.5-h1de35cc_0
  yaml               pkgs/main/osx-64::yaml-0.2.5-haf1e3a3_0
  zlib               pkgs/main/osx-64::zlib-1.2.11-h4dc903c_4


Preparing transaction: ...working... done
Executing transaction: ...working... 
done
installation finished.
Collecting package metadata (current_repodata.json): ...working... done
Solving environment: ...working... done

## Package Plan ##

  environment location: /Users/rutza/Library/r-miniconda

  added / updated specs:
    - conda


The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    brotlipy-0.7.0             |py39h89e85a6_1003         358 KB  conda-forge
    bzip2-1.0.8                |       h0d85af4_4         155 KB  conda-forge
    ca-certificates-2021.10.8  |       h033912b_0         139 KB  conda-forge
    certifi-2021.10.8          |   py39h6e9494a_1         145 KB  conda-forge
    cffi-1.15.0                |   py39he338e87_0         219 KB  conda-forge
    charset-normalizer-2.0.12  |     pyhd8ed1ab_0          35 KB  conda-forge
    colorama-0.4.4             |     pyh9f0ad1d_0          18 KB  conda-forge
    conda-4.11.0               |   py39h6e9494a_0        16.9 MB  conda-forge
    conda-package-handling-1.7.3|   py39h89e85a6_1         1.7 MB  conda-forge
    idna-3.3                   |     pyhd8ed1ab_0          55 KB  conda-forge
    libffi-3.4.2               |       h0d85af4_5          50 KB  conda-forge
    libzlib-1.2.11             |    h9173be1_1013          58 KB  conda-forge
    ncurses-6.3                |       he49afe7_0         926 KB  conda-forge
    openssl-3.0.0              |       h0d85af4_2         2.5 MB  conda-forge
    pip-22.0.3                 |     pyhd8ed1ab_0         1.5 MB  conda-forge
    pycosat-0.6.3              |py39h89e85a6_1009         114 KB  conda-forge
    pycparser-2.21             |     pyhd8ed1ab_0         100 KB  conda-forge
    pyopenssl-22.0.0           |     pyhd8ed1ab_0          49 KB  conda-forge
    pysocks-1.7.1              |   py39h6e9494a_4          28 KB  conda-forge
    python-3.9.10              |hea1dfa3_2_cpython        12.5 MB  conda-forge
    python_abi-3.9             |           2_cp39           4 KB  conda-forge
    readline-8.1               |       h05e3726_0         266 KB  conda-forge
    requests-2.27.1            |     pyhd8ed1ab_0          53 KB  conda-forge
    ruamel_yaml-0.15.80        |py39h89e85a6_1006         251 KB  conda-forge
    setuptools-60.9.1          |   py39h6e9494a_0         1.2 MB  conda-forge
    six-1.16.0                 |     pyh6c4a22f_0          14 KB  conda-forge
    sqlite-3.37.0              |       h23a322b_0         1.8 MB  conda-forge
    tk-8.6.11                  |       h5dbffcc_1         3.3 MB  conda-forge
    tqdm-4.62.3                |     pyhd8ed1ab_0          80 KB  conda-forge
    tzdata-2021e               |       he74cb21_0         121 KB  conda-forge
    urllib3-1.26.8             |     pyhd8ed1ab_1         100 KB  conda-forge
    wheel-0.37.1               |     pyhd8ed1ab_0          31 KB  conda-forge
    xz-5.2.5                   |       haf1e3a3_1         228 KB  conda-forge
    yaml-0.2.5                 |       h0d85af4_2          82 KB  conda-forge
    zlib-1.2.11                |    h9173be1_1013          87 KB  conda-forge
    ------------------------------------------------------------
                                           Total:        44.9 MB

The following NEW packages will be INSTALLED:

  bzip2              conda-forge/osx-64::bzip2-1.0.8-h0d85af4_4
  colorama           conda-forge/noarch::colorama-0.4.4-pyh9f0ad1d_0
  libzlib            conda-forge/osx-64::libzlib-1.2.11-h9173be1_1013
  python_abi         conda-forge/osx-64::python_abi-3.9-2_cp39

The following packages will be REMOVED:

  conda-content-trust-0.1.1-pyhd3eb1b0_0
  libcxx-12.0.0-h2f01273_0

The following packages will be UPDATED:

  charset-normalizer pkgs/main::charset-normalizer-2.0.4-p~ --> conda-forge::charset-normalizer-2.0.12-pyhd8ed1ab_0
  libffi                   pkgs/main::libffi-3.3-hb1e8313_2 --> conda-forge::libffi-3.4.2-h0d85af4_5
  openssl              pkgs/main::openssl-1.1.1m-hca72f7f_0 --> conda-forge::openssl-3.0.0-h0d85af4_2
  pip                pkgs/main/osx-64::pip-21.2.4-py39hecd~ --> conda-forge/noarch::pip-22.0.3-pyhd8ed1ab_0
  pycosat            pkgs/main::pycosat-0.6.3-py39h9ed2024~ --> conda-forge::pycosat-0.6.3-py39h89e85a6_1009
  pyopenssl          pkgs/main::pyopenssl-21.0.0-pyhd3eb1b~ --> conda-forge::pyopenssl-22.0.0-pyhd8ed1ab_0
  pysocks            pkgs/main::pysocks-1.7.1-py39hecd8cb5~ --> conda-forge::pysocks-1.7.1-py39h6e9494a_4
  python                 pkgs/main::python-3.9.7-h88f2d9e_1 --> conda-forge::python-3.9.10-hea1dfa3_2_cpython
  setuptools         pkgs/main::setuptools-58.0.4-py39hecd~ --> conda-forge::setuptools-60.9.1-py39h6e9494a_0
  tk                        pkgs/main::tk-8.6.11-h7bc2e8c_0 --> conda-forge::tk-8.6.11-h5dbffcc_1
  urllib3            pkgs/main::urllib3-1.26.7-pyhd3eb1b0_0 --> conda-forge::urllib3-1.26.8-pyhd8ed1ab_1
  xz                         pkgs/main::xz-5.2.5-h1de35cc_0 --> conda-forge::xz-5.2.5-haf1e3a3_1
  yaml                     pkgs/main::yaml-0.2.5-haf1e3a3_0 --> conda-forge::yaml-0.2.5-h0d85af4_2
  zlib                    pkgs/main::zlib-1.2.11-h4dc903c_4 --> conda-forge::zlib-1.2.11-h9173be1_1013

The following packages will be SUPERSEDED by a higher-priority channel:

  brotlipy           pkgs/main::brotlipy-0.7.0-py39h9ed202~ --> conda-forge::brotlipy-0.7.0-py39h89e85a6_1003
  ca-certificates    pkgs/main::ca-certificates-2021.10.26~ --> conda-forge::ca-certificates-2021.10.8-h033912b_0
  certifi            pkgs/main::certifi-2021.10.8-py39hecd~ --> conda-forge::certifi-2021.10.8-py39h6e9494a_1
  cffi                pkgs/main::cffi-1.15.0-py39hc55c11b_1 --> conda-forge::cffi-1.15.0-py39he338e87_0
  conda              pkgs/main::conda-4.11.0-py39hecd8cb5_0 --> conda-forge::conda-4.11.0-py39h6e9494a_0
  conda-package-han~ pkgs/main::conda-package-handling-1.7~ --> conda-forge::conda-package-handling-1.7.3-py39h89e85a6_1
  idna                     pkgs/main::idna-3.3-pyhd3eb1b0_0 --> conda-forge::idna-3.3-pyhd8ed1ab_0
  ncurses                 pkgs/main::ncurses-6.3-hca72f7f_2 --> conda-forge::ncurses-6.3-he49afe7_0
  pycparser          pkgs/main::pycparser-2.21-pyhd3eb1b0_0 --> conda-forge::pycparser-2.21-pyhd8ed1ab_0
  readline             pkgs/main::readline-8.1.2-hca72f7f_1 --> conda-forge::readline-8.1-h05e3726_0
  requests           pkgs/main::requests-2.27.1-pyhd3eb1b0~ --> conda-forge::requests-2.27.1-pyhd8ed1ab_0
  ruamel_yaml        pkgs/main::ruamel_yaml-0.15.100-py39h~ --> conda-forge::ruamel_yaml-0.15.80-py39h89e85a6_1006
  six                    pkgs/main::six-1.16.0-pyhd3eb1b0_0 --> conda-forge::six-1.16.0-pyh6c4a22f_0
  sqlite                pkgs/main::sqlite-3.37.0-h707629a_0 --> conda-forge::sqlite-3.37.0-h23a322b_0
  tqdm                  pkgs/main::tqdm-4.62.3-pyhd3eb1b0_1 --> conda-forge::tqdm-4.62.3-pyhd8ed1ab_0
  tzdata                 pkgs/main::tzdata-2021e-hda174b7_0 --> conda-forge::tzdata-2021e-he74cb21_0
  wheel                pkgs/main::wheel-0.37.1-pyhd3eb1b0_0 --> conda-forge::wheel-0.37.1-pyhd8ed1ab_0



Downloading and Extracting Packages
bzip2-1.0.8          | 155 KB    | ########## | 100% 
yaml-0.2.5           | 82 KB     | ########## | 100% 
pyopenssl-22.0.0     | 49 KB     | ########## | 100% 
python_abi-3.9       | 4 KB      | ########## | 100% 
ruamel_yaml-0.15.80  | 251 KB    | ########## | 100% 
sqlite-3.37.0        | 1.8 MB    | ########## | 100% 
tk-8.6.11            | 3.3 MB    | ########## | 100% 
tzdata-2021e         | 121 KB    | ########## | 100% 
wheel-0.37.1         | 31 KB     | ########## | 100% 
zlib-1.2.11          | 87 KB     | ########## | 100% 
libffi-3.4.2         | 50 KB     | ########## | 100% 
conda-4.11.0         | 16.9 MB   | ########## | 100% 
colorama-0.4.4       | 18 KB     | ########## | 100% 
cffi-1.15.0          | 219 KB    | ########## | 100% 
ca-certificates-2021 | 139 KB    | ########## | 100% 
brotlipy-0.7.0       | 358 KB    | ########## | 100% 
ncurses-6.3          | 926 KB    | ########## | 100% 
urllib3-1.26.8       | 100 KB    | ########## | 100% 
openssl-3.0.0        | 2.5 MB    | ########## | 100% 
idna-3.3             | 55 KB     | ########## | 100% 
six-1.16.0           | 14 KB     | ########## | 100% 
setuptools-60.9.1    | 1.2 MB    | ########## | 100% 
readline-8.1         | 266 KB    | ########## | 100% 
certifi-2021.10.8    | 145 KB    | ########## | 100% 
libzlib-1.2.11       | 58 KB     | ########## | 100% 
charset-normalizer-2 | 35 KB     | ########## | 100% 
pycparser-2.21       | 100 KB    | ########## | 100% 
pycosat-0.6.3        | 114 KB    | ########## | 100% 
conda-package-handli | 1.7 MB    | ########## | 100% 
tqdm-4.62.3          | 80 KB     | ########## | 100% 
pysocks-1.7.1        | 28 KB     | ########## | 100% 
python-3.9.10        | 12.5 MB   | ########## | 100% 
pip-22.0.3           | 1.5 MB    | ########## | 100% 
xz-5.2.5             | 228 KB    | ########## | 100% 
requests-2.27.1      | 53 KB     | ########## | 100% 
Preparing transaction: ...working... done
Verifying transaction: ...working... done
Executing transaction: ...working... done
Collecting package metadata (current_repodata.json): ...working... done
Solving environment: ...working... done

## Package Plan ##

  environment location: /Users/rutza/Library/r-miniconda/envs/r-reticulate

  added / updated specs:
    - numpy
    - python=3.8


The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    libblas-3.9.0              |13_osx64_openblas          12 KB  conda-forge
    libcblas-3.9.0             |13_osx64_openblas          12 KB  conda-forge
    libcxx-12.0.1              |       habf9029_1         1.1 MB  conda-forge
    libgfortran-5.0.0          |9_3_0_h6c81a4c_23          19 KB  conda-forge
    libgfortran5-9.3.0         |      h6c81a4c_23         1.7 MB  conda-forge
    liblapack-3.9.0            |13_osx64_openblas          12 KB  conda-forge
    libopenblas-0.3.18         |openmp_h3351f45_0         9.0 MB  conda-forge
    llvm-openmp-13.0.1         |       hda6cdc1_0         305 KB  conda-forge
    numpy-1.22.2               |   py38h9d72dae_0         6.3 MB  conda-forge
    python-3.8.12              |h43ca1e7_3_cpython        12.4 MB  conda-forge
    python_abi-3.8             |           2_cp38           4 KB  conda-forge
    setuptools-60.9.1          |   py38h50d1736_0         1.2 MB  conda-forge
    ------------------------------------------------------------
                                           Total:        32.0 MB

The following NEW packages will be INSTALLED:

  ca-certificates    conda-forge/osx-64::ca-certificates-2021.10.8-h033912b_0
  libblas            conda-forge/osx-64::libblas-3.9.0-13_osx64_openblas
  libcblas           conda-forge/osx-64::libcblas-3.9.0-13_osx64_openblas
  libcxx             conda-forge/osx-64::libcxx-12.0.1-habf9029_1
  libffi             conda-forge/osx-64::libffi-3.4.2-h0d85af4_5
  libgfortran        conda-forge/osx-64::libgfortran-5.0.0-9_3_0_h6c81a4c_23
  libgfortran5       conda-forge/osx-64::libgfortran5-9.3.0-h6c81a4c_23
  liblapack          conda-forge/osx-64::liblapack-3.9.0-13_osx64_openblas
  libopenblas        conda-forge/osx-64::libopenblas-0.3.18-openmp_h3351f45_0
  libzlib            conda-forge/osx-64::libzlib-1.2.11-h9173be1_1013
  llvm-openmp        conda-forge/osx-64::llvm-openmp-13.0.1-hda6cdc1_0
  ncurses            conda-forge/osx-64::ncurses-6.3-he49afe7_0
  numpy              conda-forge/osx-64::numpy-1.22.2-py38h9d72dae_0
  openssl            conda-forge/osx-64::openssl-3.0.0-h0d85af4_2
  pip                conda-forge/noarch::pip-22.0.3-pyhd8ed1ab_0
  python             conda-forge/osx-64::python-3.8.12-h43ca1e7_3_cpython
  python_abi         conda-forge/osx-64::python_abi-3.8-2_cp38
  readline           conda-forge/osx-64::readline-8.1-h05e3726_0
  setuptools         conda-forge/osx-64::setuptools-60.9.1-py38h50d1736_0
  sqlite             conda-forge/osx-64::sqlite-3.37.0-h23a322b_0
  tk                 conda-forge/osx-64::tk-8.6.11-h5dbffcc_1
  wheel              conda-forge/noarch::wheel-0.37.1-pyhd8ed1ab_0
  xz                 conda-forge/osx-64::xz-5.2.5-haf1e3a3_1
  zlib               conda-forge/osx-64::zlib-1.2.11-h9173be1_1013


Preparing transaction: ...working... done
Verifying transaction: ...working... done
Executing transaction: ...working... done
* Miniconda has been successfully installed at "~/Library/r-miniconda".
[1] "/Users/rutza/Library/r-miniconda"
> reticulate::conda_install('r-reticulate', 'python-kaleido')
Collecting package metadata (current_repodata.json): ...working... done
Solving environment: ...working... done

## Package Plan ##

  environment location: /Users/rutza/Library/r-miniconda/envs/r-reticulate

  added / updated specs:
    - python-kaleido


The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    kaleido-core-0.2.1         |       h0d85af4_0        71.9 MB  conda-forge
    mathjax-2.7.7              |                0        21.3 MB  conda-forge
    python-kaleido-0.2.1       |     pyhd8ed1ab_0          18 KB  conda-forge
    ------------------------------------------------------------
                                           Total:        93.2 MB

The following NEW packages will be INSTALLED:

  kaleido-core       conda-forge/osx-64::kaleido-core-0.2.1-h0d85af4_0
  mathjax            conda-forge/osx-64::mathjax-2.7.7-0
  python-kaleido     conda-forge/noarch::python-kaleido-0.2.1-pyhd8ed1ab_0



Downloading and Extracting Packages
kaleido-core-0.2.1   | 71.9 MB   | ########## | 100% 
mathjax-2.7.7        | 21.3 MB   | ########## | 100% 
python-kaleido-0.2.1 | 18 KB     | ########## | 100% 
Preparing transaction: ...working... done
Verifying transaction: ...working... done
Executing transaction: ...working... done
> reticulate::conda_install('r-reticulate', 'plotly', channel = 'plotly')
Collecting package metadata (current_repodata.json): ...working... done
Solving environment: ...working... done

## Package Plan ##

  environment location: /Users/rutza/Library/r-miniconda/envs/r-reticulate

  added / updated specs:
    - plotly


The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    plotly-5.6.0               |             py_0         6.9 MB  plotly
    tenacity-8.0.1             |     pyhd8ed1ab_0          21 KB  conda-forge
    ------------------------------------------------------------
                                           Total:         7.0 MB

The following NEW packages will be INSTALLED:

  plotly             plotly/noarch::plotly-5.6.0-py_0
  six                conda-forge/noarch::six-1.16.0-pyh6c4a22f_0
  tenacity           conda-forge/noarch::tenacity-8.0.1-pyhd8ed1ab_0



Downloading and Extracting Packages
plotly-5.6.0         | 6.9 MB    | ########## | 100% 
tenacity-8.0.1       | 21 KB     | ########## | 100% 
Preparing transaction: ...working... done
Verifying transaction: ...working... done
Executing transaction: ...working... done
> reticulate::use_miniconda('r-reticulate')
> p <- plotly::plot_ly(x = 1:10)
> plotly::save_image(p, "test.pdf")
No trace type specified:
  Based on info supplied, a 'histogram' trace seems appropriate.
  Read more about this trace type -> https://plotly.com/r/reference/#histogram
Error in py_run_string_impl(code, local, convert) : 
  ValueError: Failed to start Kaleido subprocess. Error stream:

> sessionInfo()
R version 4.1.2 (2021-11-01)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Monterey 12.3

Matrix products: default
LAPACK: /Library/Frameworks/R.framework/Versions/4.1/Resources/lib/libRlapack.dylib

locale:
[1] fr_CH.UTF-8/fr_CH.UTF-8/fr_CH.UTF-8/C/fr_CH.UTF-8/fr_CH.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.8        pillar_1.7.0      compiler_4.1.2    tools_4.1.2       digest_0.6.29    
 [6] viridisLite_0.4.0 jsonlite_1.7.3    lifecycle_1.0.1   tibble_3.1.6      gtable_0.3.0     
[11] lattice_0.20-45   pkgconfig_2.0.3   png_0.1-7         rlang_1.0.1       Matrix_1.4-0     
[16] cli_3.2.0         DBI_1.1.2         crosstalk_1.2.0   fastmap_1.1.0     httr_1.4.2       
[21] dplyr_1.0.8       htmlwidgets_1.5.4 generics_0.1.2    vctrs_0.3.8       rprojroot_2.0.2  
[26] grid_4.1.2        tidyselect_1.1.1  here_1.0.1        reticulate_1.24   glue_1.6.1       
[31] data.table_1.14.2 R6_2.5.1          fansi_1.0.2       plotly_4.10.0     tidyr_1.2.0      
[36] ggplot2_3.3.5     purrr_0.3.4       magrittr_2.0.2    scales_1.1.1      ellipsis_0.3.2   
[41] htmltools_0.5.2   assertthat_0.2.1  colorspace_2.0-2  utf8_1.2.2        lazyeval_0.2.2   
[46] munsell_0.5.0     crayon_1.5.0     

Coud not find any hints with

Error in py_run_string_impl(code, local, convert) : 
  ValueError: Failed to start Kaleido subprocess. Error stream:

Hope it is the right place to report 😄

While running more in-depth could reach the following, can maybe help:

Detailed traceback:
  File "<string>", line 1, in <module>
  File "/Users/rutza/Library/r-miniconda/envs/r-reticulate/lib/python3.8/site-packages/kaleido/scopes/plotly.py", line 153, in transform
    response = self._perform_transform(
  File "/Users/rutza/Library/r-miniconda/envs/r-reticulate/lib/python3.8/site-packages/kaleido/scopes/base.py", line 293, in _perform_transform
    self._ensure_kaleido()
  File "/Users/rutza/Library/r-miniconda/envs/r-reticulate/lib/python3.8/site-packages/kaleido/scopes/base.py", line 198, in _ensure_kaleido
    raise ValueError(message)
Calls: <Anonymous> -> <Anonymous> -> <Anonymous> -> py_run_string_impl
Execution halted

I believe I'm having the same issue- my R instance hangs when trying to save a static image.
Nothing I've tried seems to fix the issue. I've tried installing a separate instance of Anaconda in a location without spaces in the directory path, re-installing packages, etc.

I'm having the same issue. I get teh same error as in above code. If I use a path instead of just a file name save_image(p, tempfile(fileext = ".png")) I get:

Error in py_run_string_impl(code, local, convert) : 
  SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape (<string>, line 1)

I did discovere the issue after transfering to a new computer. Previously it worked fine.

> sessionInfo()
R version 4.2.0 (2022-04-22 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 22000)

Matrix products: default

locale:
[1] LC_COLLATE=Finnish_Finland.utf8  LC_CTYPE=Finnish_Finland.utf8    LC_MONETARY=Finnish_Finland.utf8
[4] LC_NUMERIC=C                     LC_TIME=Finnish_Finland.utf8    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] plotly_4.10.0  ggplot2_3.3.5  testthat_3.1.4 devtools_2.4.3 usethis_2.1.5 

loaded via a namespace (and not attached):
 [1] bitops_1.0-7              fs_1.5.2                  statfitools_0.3.7.9003    lubridate_1.8.0          
 [5] fontawesome_0.2.2         httr_1.4.2                rprojroot_2.0.3           googleAuthR_2.0.0        
 [9] tools_4.2.0               backports_1.4.1           utf8_1.2.2                R6_2.5.1                 
[13] DBI_1.1.2                 lazyeval_0.2.2            colorspace_2.0-3          withr_2.5.0              
[17] tidyselect_1.1.2          prettyunits_1.1.1         processx_3.5.3            curl_4.3.2               
[21] compiler_4.2.0            cli_3.3.0                 desc_1.4.1                scales_1.2.0             
[25] callr_3.7.0               askpass_1.1               rappdirs_0.3.3            stringr_1.4.0            
[29] digest_0.6.29             rmarkdown_2.14            pkgconfig_2.0.3           htmltools_0.5.2          
[33] sessioninfo_1.2.2         fastmap_1.1.0             htmlwidgets_1.5.4         rlang_1.0.2              
[37] readxl_1.4.0              pttrobo_0.1.7             rstudioapi_0.13           generics_0.1.2           
[41] zoo_1.8-10                jsonlite_1.8.0            crosstalk_1.2.0           dplyr_1.0.8              
[45] zip_2.2.0                 car_3.0-12                RCurl_1.98-1.6            magrittr_2.0.3           
[49] Matrix_1.4-1              Rcpp_1.0.8.3              munsell_0.5.0             fansi_1.0.3              
[53] abind_1.4-5               reticulate_1.24           lifecycle_1.0.1           stringi_1.7.6            
[57] yaml_2.3.5                carData_3.0-5             brio_1.1.3                pkgbuild_1.3.1           
[61] grid_4.2.0                forcats_0.5.1             crayon_1.5.1              lattice_0.20-45          
[65] knitr_1.39                ps_1.7.0                  pillar_1.7.0              ggpubr_0.4.0             
[69] ggsignif_0.6.3            pkgload_1.2.4             glue_1.6.2                evaluate_0.15            
[73] data.table_1.14.2         remotes_2.4.2             png_0.1-7                 vctrs_0.4.1              
[77] cellranger_1.1.0          gtable_0.3.0              robonomistClient_2.2.4    openssl_2.0.0            
[81] purrr_0.3.4               tidyr_1.2.0               assertthat_0.2.1          cachem_1.0.6             
[85] xfun_0.30                 googleCloudStorageR_0.7.0 broom_0.8.0               rstatix_0.7.0            
[89] later_1.3.0               viridisLite_0.4.0         gargle_1.2.0              tibble_3.1.6             
[93] websocket_1.4.1           memoise_2.0.1             ellipsis_0.3.2            here_1.0.1   

I can't get this to run on my MacBook Pro M1 either.

p <- plot_ly(x = 1:10, y = 1:10, type = "scatter", mode = "marker")
save_image(p, "test.png")

Error in py_run_string_impl(code, local, convert) : 
  NameError: name 'sys' is not defined

I went through all the installation steps in ?plotly::save_image without issues.

install.packages('reticulate')
reticulate::install_miniconda()
reticulate::conda_install('r-reticulate', 'python-kaleido')
reticulate::conda_install('r-reticulate', 'plotly', channel = 'plotly')
reticulate::use_miniconda('r-reticulate')

I tried reticulate::import("sys") but that didn't work. Any help would be appreciated.

@mnneely I am having the same problem

commented

Error in py_run_string_impl(code, local, convert) :
NameError: name 'sys' is not defined
#not use:reticulate::import("sys")

reticulate::py_run_string("import sys")

it work!!!

Using Windows 10 and running this causes R to hang and does not render the test p:

library(reticulate)
use_miniconda('r-reticulate')
library(plotly)
p <- plot_ly(x = 1:10, y = 1:10, type = "scatter", mode = "marker")
save_image(p, "test.png")

Here is the traceback:

traceback(save_image(p, "test.png"))
Error in py_run_string_impl(code, local, convert) : 
  NameError: name 'sys' is not defined
Run `reticulate::py_last_error()` for details.
> reticulate::py_last_error()

-- Python Exception Message --------------------------------------------------------
Traceback (most recent call last):
  File "<string>", line 1, in <module>
NameError: name 'sys' is not defined

-- R Traceback ---------------------------------------------------------------------
    x
 1. +-base::traceback(save_image(p, "test.png"))
 2. | \-base::.traceback(x, max.lines = max.lines)
 3. |   \-base (local) .is.positive.intlike(x)
 4. \-plotly::save_image(p, "test.png")
 5.   \-kaleido()$transform(...)
 6.     \-reticulate::py_run_string(...)
 7.       \-reticulate:::py_run_string_impl(code, local, convert)

Current R version and sessionInfo:

R version 4.1.2 (2021-11-01) -- "Bird Hippie"
Copyright (C) 2021 The R Foundation for Statistical Computing
Platform: x86_64-w64-mingw32/x64 (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

[Workspace loaded from ~/.RData]

> sessionInfo()
R version 4.1.2 (2021-11-01)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19044)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.10          mathjaxr_1.6-0       pillar_1.9.0        
 [4] compiler_4.1.2       tools_4.1.2          metadat_1.2-0       
 [7] nlme_3.1-153         jsonlite_1.8.7       lifecycle_1.0.3     
[10] tibble_3.2.1         gtable_0.3.3         lattice_0.20-45     
[13] pkgconfig_2.0.3      png_0.1-8            rlang_1.1.1         
[16] Matrix_1.5-4         cli_3.6.1            rstudioapi_0.14     
[19] gridExtra_2.3        metafor_4.2-0        dplyr_1.1.2         
[22] generics_0.1.3       vctrs_0.6.3          grid_4.1.2          
[25] tidyselect_1.2.0     reticulate_1.31      glue_1.6.2          
[28] R6_2.5.1             fansi_1.0.4          distributional_0.3.2
[31] purrr_1.0.1          ggplot2_3.4.2        farver_2.1.1        
[34] magrittr_2.0.3       scales_1.2.1         ggdist_3.2.1        
[37] colorspace_2.1-0     numDeriv_2016.8-1.1  utf8_1.2.3          
[40] munsell_0.5.0        crayon_1.5.2     

rstudioapi::versionInfo()
$citation

To cite RStudio in publications use:

  Posit team (2023). RStudio: Integrated Development Environment for R.
  Posit Software, PBC, Boston, MA. URL http://www.posit.co/.

A BibTeX entry for LaTeX users is

  @Manual{,
    title = {RStudio: Integrated Development Environment for R},
    author = {{Posit team}},
    organization = {Posit Software, PBC},
    address = {Boston, MA},
    year = {2023},
    url = {http://www.posit.co/},
  }


$mode
[1] "desktop"

$version
[1] ‘2023.6.2.561’

$long_version
[1] "2023.06.2+561"

$release_name
[1] "Mountain Hydrangea"

Thanks for all the digging!

Did you try the extra step I mentioned in the help for export_plotly?

You need to include reticulate::py_run_string("import sys") to avoid that error. I had the same problem on my Mac.

Altogether the commands are:

install.packages('reticulate')
reticulate::install_miniconda()
reticulate::conda_install('r-reticulate', 'python-kaleido')
reticulate::conda_install('r-reticulate', 'plotly', channel = 'plotly')
reticulate::use_miniconda('r-reticulate')
reticulate::py_run_string("import sys") #this is the extra step neglected in help for save_plotly.	

My export_plotly() should run whichever of these is needed, but perhaps that part failed. I check to see if kaleido, reticulate, and minconda are installed, but maybe if there was a partial install the check failed and the installation wasn't completed.

Thansk @mnneely.

It seems like my issue might have had to do with this:
https://stackoverflow.com/questions/72197496/r-plotlysave-image-kaleido-static-export-from-r-not-working

After failing to get tmp.png with the default kalido install I backed up to an older version:

reticulate::conda_install('r-reticulate', 'python-kaleido') # not working

reticulate::conda_install('r-reticulate', 'python-kaleido==0.1.*') # works

I don't know what the issue is or why it kept on hanging though...

Good find, but frustrating I agree. I have python-kaleido 0.2.1 running on my Mac (M1) and it works. I used reticulate::py_list_packages() as an easy way to list all the Python packages installed via reticulate::conda_install().