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

error by using reticulate::install_miniconda() #1312

Closed
Zhenlone opened this issue Jan 3, 2023 · 19 comments
Closed

error by using reticulate::install_miniconda() #1312

Zhenlone opened this issue Jan 3, 2023 · 19 comments

Comments

@Zhenlone
Copy link

Zhenlone commented Jan 3, 2023

when i try to install the miniconda via reticulate::install_miniconda() the following error always pops up:

> reticulate::install_miniconda()
* Installing Miniconda -- please wait a moment ...
* Downloading "https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe" ...
trying URL 'https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe'
Content type 'application/octet-stream' length 55508040 bytes (52.9 MB)
downloaded 52.9 MB

Error: miniconda installation failed [exit code 2]

more detailed information:

> sessionInfo()
R version 4.2.2 (2022-10-31 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19045)

Matrix products: default

locale:
[1] LC_COLLATE=German_Germany.utf8 
[2] LC_CTYPE=German_Germany.utf8   
[3] LC_MONETARY=German_Germany.utf8
[4] LC_NUMERIC=C                   
[5] LC_TIME=German_Germany.utf8    

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

loaded via a namespace (and not attached):
 [1] compiler_4.2.2  here_1.0.1      Matrix_1.5-1   
 [4] rprojroot_2.0.3 tools_4.2.2     rappdirs_0.3.3 
 [7] Rcpp_1.0.9      reticulate_1.26 grid_4.2.2     
[10] jsonlite_1.8.4  png_0.1-8       lattice_0.20-45

the same error was reproduced with using another pc.

@Zhenlone Zhenlone changed the title Fail to use reticulate::install_miniconda() error by using reticulate::install_miniconda() Jan 3, 2023
@kevinushey
Copy link
Collaborator

Thanks; I'm seeing the same thing as well. Presumedly something changed in the Miniconda installer for Windows that is causing this issue; I'll take a quick look.

@kevinushey
Copy link
Collaborator

It seems like something must've changed in the Miniconda installer; it seems like something is going wrong with our attempt to run a silent / non-interactive installation.

"/S",

@t-kalinowski, are you able to investigate?

@kevinushey
Copy link
Collaborator

Thank you!

@schwa021
Copy link

This is listed as closed, but I received the exact same error just now

trying URL 'https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe'
Content type 'application/octet-stream' length 77606504 bytes (74.0 MB)
downloaded 74.0 MB

Error: miniconda installation failed [exit code 2]

RStudio
2023.09.1 Build 494

@kevinushey kevinushey reopened this Nov 27, 2023
@kevinushey
Copy link
Collaborator

@t-kalinowski can you check if something has changed in the latest version of the Miniconda installer?

@t-kalinowski
Copy link
Member

t-kalinowski commented Nov 28, 2023

I can't reproduce the error, on Windows nor macOS:

> reticulate::miniconda_uninstall()

Restarting R session...

> reticulate::install_miniconda()
* Installing Miniconda -- please wait a moment ...
* Downloading "https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe" ...
trying URL 'https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe'
Content type 'application/octet-stream' length 77606504 bytes (74.0 MB)
downloaded 74.0 MB

+ "C:/Users/kalin/AppData/Local/r-miniconda/condabin/conda.bat" update --yes --name base conda
Channels:
 - defaults
Platform: win-64
Collecting package metadata (repodata.json): ...working... done
Solving environment: ...working... done

## Package Plan ##

  environment location: C:\Users\kalin\AppData\Local\R-MINI~1

  added / updated specs:
    - conda


The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    certifi-2023.11.17         |  py311haa95532_0         160 KB
    ------------------------------------------------------------
                                           Total:         160 KB

The following packages will be UPDATED:

  certifi                         2023.7.22-py311haa95532_0 --> 2023.11.17-py311haa95532_0 



Downloading and Extracting Packages: ...working... done
Preparing transaction: ...working... done
Verifying transaction: ...working... done
Executing transaction: ...working... done
+ "C:/Users/kalin/AppData/Local/r-miniconda/condabin/conda.bat" "create" "--yes" "--name" "r-reticulate" "python=3.9" "numpy" "--quiet" "-c" "conda-forge"
Channels:
 - conda-forge
 - defaults
Platform: win-64
Collecting package metadata (repodata.json): ...working... done
Solving environment: ...working... done

## Package Plan ##

  environment location: C:\Users\kalin\AppData\Local\R-MINI~1\envs\r-reticulate

  added / updated specs:
    - numpy
    - python=3.9


The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    bzip2-1.0.8                |       hcfcfb64_5         122 KB  conda-forge
    ca-certificates-2023.11.17 |       h56e8100_0         151 KB  conda-forge
    intel-openmp-2023.2.0      |   h57928b3_50497         2.4 MB  conda-forge
    libblas-3.9.0              |     20_win64_mkl         4.8 MB  conda-forge
    libcblas-3.9.0             |     20_win64_mkl         4.8 MB  conda-forge
    libffi-3.4.2               |       h8ffe710_5          41 KB  conda-forge
    libhwloc-2.9.3             |default_haede6df_1009         2.5 MB  conda-forge
    libiconv-1.17              |       h8ffe710_0         698 KB  conda-forge
    liblapack-3.9.0            |     20_win64_mkl         4.8 MB  conda-forge
    libsqlite-3.44.2           |       hcfcfb64_0         833 KB  conda-forge
    libxml2-2.11.6             |       hc3477c8_0         1.6 MB  conda-forge
    libzlib-1.2.13             |       hcfcfb64_5          54 KB  conda-forge
    mkl-2023.2.0               |   h6a75c08_50497       138.0 MB  conda-forge
    numpy-1.26.2               |   py39hddb5d58_0         5.7 MB  conda-forge
    openssl-3.2.0              |       hcfcfb64_0         7.8 MB  conda-forge
    pip-23.3.1                 |     pyhd8ed1ab_0         1.3 MB  conda-forge
    pthreads-win32-2.9.1       |       hfa6e2cd_3         141 KB  conda-forge
    python-3.9.18              |h4de0772_0_cpython        16.1 MB  conda-forge
    python_abi-3.9             |           4_cp39           7 KB  conda-forge
    setuptools-68.2.2          |     pyhd8ed1ab_0         454 KB  conda-forge
    tbb-2021.10.0              |       h91493d7_2         153 KB  conda-forge
    tk-8.6.13                  |       h5226925_1         3.3 MB  conda-forge
    tzdata-2023c               |       h71feb2d_0         115 KB  conda-forge
    ucrt-10.0.22621.0          |       h57928b3_0         1.2 MB  conda-forge
    vc-14.3                    |      h64f974e_17          17 KB  conda-forge
    vc14_runtime-14.36.32532   |      hdcecf7f_17         722 KB  conda-forge
    vs2015_runtime-14.36.32532 |      h05e6639_17          17 KB  conda-forge
    wheel-0.42.0               |     pyhd8ed1ab_0          56 KB  conda-forge
    xz-5.2.6                   |       h8d14728_0         213 KB  conda-forge
    ------------------------------------------------------------
                                           Total:       197.8 MB

The following NEW packages will be INSTALLED:

  bzip2              conda-forge/win-64::bzip2-1.0.8-hcfcfb64_5 
  ca-certificates    conda-forge/win-64::ca-certificates-2023.11.17-h56e8100_0 
  intel-openmp       conda-forge/win-64::intel-openmp-2023.2.0-h57928b3_50497 
  libblas            conda-forge/win-64::libblas-3.9.0-20_win64_mkl 
  libcblas           conda-forge/win-64::libcblas-3.9.0-20_win64_mkl 
  libffi             conda-forge/win-64::libffi-3.4.2-h8ffe710_5 
  libhwloc           conda-forge/win-64::libhwloc-2.9.3-default_haede6df_1009 
  libiconv           conda-forge/win-64::libiconv-1.17-h8ffe710_0 
  liblapack          conda-forge/win-64::liblapack-3.9.0-20_win64_mkl 
  libsqlite          conda-forge/win-64::libsqlite-3.44.2-hcfcfb64_0 
  libxml2            conda-forge/win-64::libxml2-2.11.6-hc3477c8_0 
  libzlib            conda-forge/win-64::libzlib-1.2.13-hcfcfb64_5 
  mkl                conda-forge/win-64::mkl-2023.2.0-h6a75c08_50497 
  numpy              conda-forge/win-64::numpy-1.26.2-py39hddb5d58_0 
  openssl            conda-forge/win-64::openssl-3.2.0-hcfcfb64_0 
  pip                conda-forge/noarch::pip-23.3.1-pyhd8ed1ab_0 
  pthreads-win32     conda-forge/win-64::pthreads-win32-2.9.1-hfa6e2cd_3 
  python             conda-forge/win-64::python-3.9.18-h4de0772_0_cpython 
  python_abi         conda-forge/win-64::python_abi-3.9-4_cp39 
  setuptools         conda-forge/noarch::setuptools-68.2.2-pyhd8ed1ab_0 
  tbb                conda-forge/win-64::tbb-2021.10.0-h91493d7_2 
  tk                 conda-forge/win-64::tk-8.6.13-h5226925_1 
  tzdata             conda-forge/noarch::tzdata-2023c-h71feb2d_0 
  ucrt               conda-forge/win-64::ucrt-10.0.22621.0-h57928b3_0 
  vc                 conda-forge/win-64::vc-14.3-h64f974e_17 
  vc14_runtime       conda-forge/win-64::vc14_runtime-14.36.32532-hdcecf7f_17 
  vs2015_runtime     conda-forge/win-64::vs2015_runtime-14.36.32532-h05e6639_17 
  wheel              conda-forge/noarch::wheel-0.42.0-pyhd8ed1ab_0 
  xz                 conda-forge/win-64::xz-5.2.6-h8d14728_0 


Preparing transaction: ...working... done
Verifying transaction: ...working... done
Executing transaction: ...working... done
* Miniconda has been successfully installed at "C:/Users/kalin/AppData/Local/r-miniconda".
[1] "C:/Users/kalin/AppData/Local/r-miniconda"
> 

@kevinushey
Copy link
Collaborator

Thanks -- @schwa021 we're going to need more information in order to understand why this isn't working on your machine. Can you please file a new issue with more details?

@karstensuhre
Copy link

I am having the same problem on Windows. I can see a window with a download progress bar advancing, and exactly after 60 sec the error is thrown. I believe that the error only occurs if the internet connection is too slow for the download to finish before the timeout.

The error message includes :

downloaded length 35387752 != reported length 84375104

which suggests that there is no sync between the download process and the rest of the install.

And it also explains why the error cannot always be reproduced.

@karstensuhre
Copy link

Here the full error message:

reticulate::install_miniconda()

Error in download.file(url, destfile = installer, mode = "wb") :
download from 'https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe' failed
In addition: Warning messages:
1: In download.file(url, destfile = installer, mode = "wb") :
downloaded length 35387752 != reported length 84375104
2: In download.file(url, destfile = installer, mode = "wb") :
URL 'https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe': Timeout of 60 seconds was reached

@matthewgson
Copy link

@karstensuhre It seems your internet speed is limited, so it couldn't download the full installer before the default 60 second timeout. Try increasing the timeout properly options(timeout=500)

@sgkeith
Copy link

sgkeith commented Feb 29, 2024

Hi,

I am set up with RStudio Server on Ubuntu 22.04 with WSL2.

From 'rstudio/tensorflow#510'
All went OK Running:
install.packages("remotes")
remotes::install_github(sprintf("rstudio/%s", c("reticulate", "tensorflow", "keras")))

But after:

reticulate::install_miniconda()

Error in download.file(url, destfile = installer, mode = "wb") :
download from 'https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh' failed
In addition: Warning messages:
1: In download.file(url, destfile = installer, mode = "wb") :
downloaded length 0 != reported length 0
2: In download.file(url, destfile = installer, mode = "wb") :
URL 'https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh': Timeout of 60 seconds was reached

I then tried:

reticulate::miniconda_uninstall()
options(timeout=500)
reticulate::install_miniconda()

  • Installing Miniconda -- please wait a moment ...
    PREFIX=/home/sgk_ubuntu/.local/share/r-miniconda
    WARNING: md5sum mismatch of tar archive
    expected: 2813fcaa6939fce035765d570fef4971
    got: 016a2ada03d3e416c978c98b7f4f4f42 -
    Unpacking payload ...
    Traceback (most recent call last):
    File "entry_point.py", line 294, in
    File "entry_point.py", line 286, in main
    File "entry_point.py", line 197, in _constructor_subcommand
    File "entry_point.py", line 168, in _constructor_extract_tarball
    File "tarfile.py", line 2264, in extractall
    File "tarfile.py", line 2327, in _extract_one
    File "tarfile.py", line 2410, in _extract_member
    File "tarfile.py", line 2463, in makefile
    File "tarfile.py", line 254, in copyfileobj
    tarfile.ReadError: unexpected end of data
    [9781] Failed to execute script 'entry_point' due to unhandled exception!
    Error: miniconda installation failed [exit code 1]

...And I am now out of ideas!

@t-kalinowski
Copy link
Member

Hi @sgkeith, are you able to install a venv instead of miniconda?

reticulate::install_python()
reticulate::virtualenv_create(force=TRUE)

@sgkeith
Copy link

sgkeith commented Feb 29, 2024

Hello again,

Thanks for getting back to me so quickly.

Just now realising I hadn't done the whole hog...
remove.packages("reticulate", lib="/R/x86_64-pc-linux-gnu-library/4.3")
remove.packages("tensorflow", lib="
/R/x86_64-pc-linux-gnu-library/4.3")
remove.packages("keras3", lib="~/R/x86_64-pc-linux-gnu-library/4.3")

re-start R (F10)

Then:

remotes::install_github(sprintf("rstudio/%s", c("reticulate", "tensorflow", "keras")))

And try this again..

reticulate::miniconda_uninstall()
options(timeout=500)
reticulate::install_miniconda()

The above worked, so progressing with your other suggested commands, now I have:
(noticing that keras is now keras3)

Restarting R session...

library(tensorflow)
library(keras3)
keras3::install_keras()

Error in stop_no_virtualenv_starter(version = version, python = python) :
Suitable Python installation for creating a venv not found.
Requested Python: /usr/bin/python3.10
Requested version constraint: >=3.9,<=3.11
Please install Python with one of following methods:

@t-kalinowski
Copy link
Member

t-kalinowski commented Feb 29, 2024

Can you follow the instructions in the error message?

Please install Python with one of following methods:

@sgkeith
Copy link

sgkeith commented Mar 3, 2024

Hi,

Thank you.

Yes, though the only method that worked for me was with WSL following: https://github.com/rstudio/python-builds/

sgk_ubuntu@DESKTOP-84TA6HQ:/mnt/c/Windows/system32$ PYTHON_VERSION=3.10.13
sgk_ubuntu@DESKTOP-84TA6HQ:/mnt/c/Windows/system32$ wget https://cdn.rstudio.com/python/ubuntu-2204/pkgs/python-${PYTHON_VERSION}_1_amd64.deb
sgk_ubuntu@DESKTOP-84TA6HQ:/mnt/c/Windows/system32$ sudo apt-get install gdebi-core
sgk_ubuntu@DESKTOP-84TA6HQ:/mnt/c/Windows/system32$ /opt/python/${PYTHON_VERSION}/bin/python --version
sgk_ubuntu@DESKTOP-84TA6HQ:/mnt/c/Windows/system32$ sudo ln -s /opt/python/${PYTHON_VERSION}/bin/python /usr/local/bin/python

I think my previous error was that I hadn't added Python to PATH.

I am now having a recurring problem. Miniconda installs OK but keras / keras3::install_keras().
It fails at:

Building wheel for promise (setup.py): finished with status 'error'
  error: subprocess-exited-with-error
  
  × python setup.py bdist_wheel did not run successfully.

All the code (sorry!)

# Restarting R session...
options(timeout=500)
install.packages("remotes")
remotes::install_github(sprintf("rstudio/%s", c("reticulate", "tensorflow", "keras")))
reticulate::miniconda_uninstall() # start with a blank slate
reticulate::install_miniconda()
keras::install_keras()
> keras::install_keras()
Error in loadNamespace(x) : there is no package called ‘keras’
> keras3::install_keras()
Virtual environment 'r-keras' removed.
Using Python: /home/sgk_ubuntu/.pyenv/versions/3.10.13/bin/python3.10
Creating virtual environment 'r-keras' ... 
+ /home/sgk_ubuntu/.pyenv/versions/3.10.13/bin/python3.10 -m venv /home/sgk_ubuntu/.virtualenvs/r-keras
Done!
Installing packages: pip, wheel, setuptools
+ /home/sgk_ubuntu/.virtualenvs/r-keras/bin/python -m pip install --upgrade pip wheel setuptools
Requirement already satisfied: pip in /home/sgk_ubuntu/.virtualenvs/r-keras/lib/python3.10/site-packages (23.0.1)
Collecting pip
  Using cached pip-24.0-py3-none-any.whl (2.1 MB)
Collecting wheel
  Using cached wheel-0.42.0-py3-none-any.whl (65 kB)
Requirement already satisfied: setuptools in /home/sgk_ubuntu/.virtualenvs/r-keras/lib/python3.10/site-packages (65.5.0)
Collecting setuptools
  Using cached setuptools-69.1.1-py3-none-any.whl (819 kB)
Installing collected packages: wheel, setuptools, pip
  Attempting uninstall: setuptools
    Found existing installation: setuptools 65.5.0
    Uninstalling setuptools-65.5.0:
      Successfully uninstalled setuptools-65.5.0
  Attempting uninstall: pip
    Found existing installation: pip 23.0.1
    Uninstalling pip-23.0.1:
      Successfully uninstalled pip-23.0.1
Successfully installed pip-24.0 setuptools-69.1.1 wheel-0.42.0
Virtual environment 'r-keras' successfully created.
Using virtual environment 'r-keras' ...
+ /home/sgk_ubuntu/.virtualenvs/r-keras/bin/python -m pip install --upgrade --no-user scipy pandas Pillow pydot ipython tensorflow_datasets packaging
Collecting scipy
  Using cached scipy-1.12.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (60 kB)
Collecting pandas
  Using cached pandas-2.2.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (19 kB)
Collecting Pillow
  Using cached pillow-10.2.0-cp310-cp310-manylinux_2_28_x86_64.whl.metadata (9.7 kB)
Collecting pydot
  Using cached pydot-2.0.0-py3-none-any.whl.metadata (9.6 kB)
Collecting ipython
  Using cached ipython-8.22.1-py3-none-any.whl.metadata (4.8 kB)
Collecting tensorflow_datasets
  Using cached tensorflow_datasets-4.9.4-py3-none-any.whl.metadata (9.2 kB)
Collecting packaging
  Using cached packaging-23.2-py3-none-any.whl.metadata (3.2 kB)
Collecting numpy<1.29.0,>=1.22.4 (from scipy)
  Using cached numpy-1.26.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (61 kB)
Collecting python-dateutil>=2.8.2 (from pandas)
  Using cached python_dateutil-2.9.0.post0-py2.py3-none-any.whl.metadata (8.4 kB)
Collecting pytz>=2020.1 (from pandas)
  Using cached pytz-2024.1-py2.py3-none-any.whl.metadata (22 kB)
Collecting tzdata>=2022.7 (from pandas)
  Using cached tzdata-2024.1-py2.py3-none-any.whl.metadata (1.4 kB)
Collecting pyparsing>=3 (from pydot)
  Using cached pyparsing-3.1.1-py3-none-any.whl.metadata (5.1 kB)
Collecting decorator (from ipython)
  Using cached decorator-5.1.1-py3-none-any.whl.metadata (4.0 kB)
Collecting jedi>=0.16 (from ipython)
  Using cached jedi-0.19.1-py2.py3-none-any.whl.metadata (22 kB)
Collecting matplotlib-inline (from ipython)
  Using cached matplotlib_inline-0.1.6-py3-none-any.whl.metadata (2.8 kB)
Collecting prompt-toolkit<3.1.0,>=3.0.41 (from ipython)
  Using cached prompt_toolkit-3.0.43-py3-none-any.whl.metadata (6.5 kB)
Collecting pygments>=2.4.0 (from ipython)
  Using cached pygments-2.17.2-py3-none-any.whl.metadata (2.6 kB)
Collecting stack-data (from ipython)
  Using cached stack_data-0.6.3-py3-none-any.whl.metadata (18 kB)
Collecting traitlets>=5.13.0 (from ipython)
  Using cached traitlets-5.14.1-py3-none-any.whl.metadata (10 kB)
Collecting exceptiongroup (from ipython)
  Using cached exceptiongroup-1.2.0-py3-none-any.whl.metadata (6.6 kB)
Collecting pexpect>4.3 (from ipython)
  Using cached pexpect-4.9.0-py2.py3-none-any.whl.metadata (2.5 kB)
Collecting absl-py (from tensorflow_datasets)
  Using cached absl_py-2.1.0-py3-none-any.whl.metadata (2.3 kB)
Collecting click (from tensorflow_datasets)
  Using cached click-8.1.7-py3-none-any.whl.metadata (3.0 kB)
Collecting dm-tree (from tensorflow_datasets)
  Using cached dm_tree-0.1.8-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (1.9 kB)
Collecting etils>=0.9.0 (from etils[enp,epath,etree]>=0.9.0->tensorflow_datasets)
  Using cached etils-1.7.0-py3-none-any.whl.metadata (6.4 kB)
Collecting promise (from tensorflow_datasets)
  Using cached promise-2.3.tar.gz (19 kB)
  Preparing metadata (setup.py): started
  Preparing metadata (setup.py): finished with status 'done'
Collecting protobuf>=3.20 (from tensorflow_datasets)
  Using cached protobuf-4.25.3-cp37-abi3-manylinux2014_x86_64.whl.metadata (541 bytes)
Collecting psutil (from tensorflow_datasets)
  Using cached psutil-5.9.8-cp36-abi3-manylinux_2_12_x86_64.manylinux2010_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (21 kB)
Collecting requests>=2.19.0 (from tensorflow_datasets)
  Using cached requests-2.31.0-py3-none-any.whl.metadata (4.6 kB)
Collecting tensorflow-metadata (from tensorflow_datasets)
  Using cached tensorflow_metadata-1.14.0-py3-none-any.whl.metadata (2.1 kB)
Collecting termcolor (from tensorflow_datasets)
  Using cached termcolor-2.4.0-py3-none-any.whl.metadata (6.1 kB)
Collecting toml (from tensorflow_datasets)
  Using cached toml-0.10.2-py2.py3-none-any.whl.metadata (7.1 kB)
Collecting tqdm (from tensorflow_datasets)
  Using cached tqdm-4.66.2-py3-none-any.whl.metadata (57 kB)
Collecting wrapt (from tensorflow_datasets)
  Using cached wrapt-1.16.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (6.6 kB)
Collecting array-record>=0.5.0 (from tensorflow_datasets)
  Using cached array_record-0.5.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (503 bytes)
Collecting fsspec (from etils[enp,epath,etree]>=0.9.0->tensorflow_datasets)
  Using cached fsspec-2024.2.0-py3-none-any.whl.metadata (6.8 kB)
Collecting importlib_resources (from etils[enp,epath,etree]>=0.9.0->tensorflow_datasets)
  Using cached importlib_resources-6.1.2-py3-none-any.whl.metadata (3.9 kB)
Collecting typing_extensions (from etils[enp,epath,etree]>=0.9.0->tensorflow_datasets)
  Using cached typing_extensions-4.10.0-py3-none-any.whl.metadata (3.0 kB)
Collecting zipp (from etils[enp,epath,etree]>=0.9.0->tensorflow_datasets)
  Using cached zipp-3.17.0-py3-none-any.whl.metadata (3.7 kB)
Collecting parso<0.9.0,>=0.8.3 (from jedi>=0.16->ipython)
  Using cached parso-0.8.3-py2.py3-none-any.whl.metadata (7.5 kB)
Collecting ptyprocess>=0.5 (from pexpect>4.3->ipython)
  Using cached ptyprocess-0.7.0-py2.py3-none-any.whl.metadata (1.3 kB)
Collecting wcwidth (from prompt-toolkit<3.1.0,>=3.0.41->ipython)
  Using cached wcwidth-0.2.13-py2.py3-none-any.whl.metadata (14 kB)
Collecting six>=1.5 (from python-dateutil>=2.8.2->pandas)
  Using cached six-1.16.0-py2.py3-none-any.whl.metadata (1.8 kB)
Collecting charset-normalizer<4,>=2 (from requests>=2.19.0->tensorflow_datasets)
  Using cached charset_normalizer-3.3.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (33 kB)
Collecting idna<4,>=2.5 (from requests>=2.19.0->tensorflow_datasets)
  Using cached idna-3.6-py3-none-any.whl.metadata (9.9 kB)
Collecting urllib3<3,>=1.21.1 (from requests>=2.19.0->tensorflow_datasets)
  Using cached urllib3-2.2.1-py3-none-any.whl.metadata (6.4 kB)
Collecting certifi>=2017.4.17 (from requests>=2.19.0->tensorflow_datasets)
  Using cached certifi-2024.2.2-py3-none-any.whl.metadata (2.2 kB)
Collecting executing>=1.2.0 (from stack-data->ipython)
  Using cached executing-2.0.1-py2.py3-none-any.whl.metadata (9.0 kB)
Collecting asttokens>=2.1.0 (from stack-data->ipython)
  Using cached asttokens-2.4.1-py2.py3-none-any.whl.metadata (5.2 kB)
Collecting pure-eval (from stack-data->ipython)
  Using cached pure_eval-0.2.2-py3-none-any.whl.metadata (6.2 kB)
Collecting absl-py (from tensorflow_datasets)
  Using cached absl_py-1.4.0-py3-none-any.whl.metadata (2.3 kB)
Collecting googleapis-common-protos<2,>=1.52.0 (from tensorflow-metadata->tensorflow_datasets)
  Using cached googleapis_common_protos-1.62.0-py2.py3-none-any.whl.metadata (1.5 kB)
Collecting protobuf>=3.20 (from tensorflow_datasets)
  Using cached protobuf-3.20.3-cp310-cp310-manylinux_2_12_x86_64.manylinux2010_x86_64.whl.metadata (679 bytes)
Using cached scipy-1.12.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (38.4 MB)
Using cached pandas-2.2.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (13.0 MB)
Using cached pillow-10.2.0-cp310-cp310-manylinux_2_28_x86_64.whl (4.5 MB)
Using cached pydot-2.0.0-py3-none-any.whl (22 kB)
Using cached ipython-8.22.1-py3-none-any.whl (811 kB)
Using cached tensorflow_datasets-4.9.4-py3-none-any.whl (5.1 MB)
Using cached packaging-23.2-py3-none-any.whl (53 kB)
Using cached array_record-0.5.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.0 MB)
Using cached etils-1.7.0-py3-none-any.whl (152 kB)
Using cached jedi-0.19.1-py2.py3-none-any.whl (1.6 MB)
Using cached numpy-1.26.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (18.2 MB)
Using cached pexpect-4.9.0-py2.py3-none-any.whl (63 kB)
Using cached prompt_toolkit-3.0.43-py3-none-any.whl (386 kB)
Using cached pygments-2.17.2-py3-none-any.whl (1.2 MB)
Using cached pyparsing-3.1.1-py3-none-any.whl (103 kB)
Using cached python_dateutil-2.9.0.post0-py2.py3-none-any.whl (229 kB)
Using cached pytz-2024.1-py2.py3-none-any.whl (505 kB)
Using cached requests-2.31.0-py3-none-any.whl (62 kB)
Using cached traitlets-5.14.1-py3-none-any.whl (85 kB)
Using cached tzdata-2024.1-py2.py3-none-any.whl (345 kB)
Using cached click-8.1.7-py3-none-any.whl (97 kB)
Using cached decorator-5.1.1-py3-none-any.whl (9.1 kB)
Using cached dm_tree-0.1.8-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (152 kB)
Using cached exceptiongroup-1.2.0-py3-none-any.whl (16 kB)
Using cached matplotlib_inline-0.1.6-py3-none-any.whl (9.4 kB)
Using cached psutil-5.9.8-cp36-abi3-manylinux_2_12_x86_64.manylinux2010_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (288 kB)
Using cached stack_data-0.6.3-py3-none-any.whl (24 kB)
Using cached tensorflow_metadata-1.14.0-py3-none-any.whl (28 kB)
Using cached absl_py-1.4.0-py3-none-any.whl (126 kB)
Using cached protobuf-3.20.3-cp310-cp310-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (1.1 MB)
Using cached termcolor-2.4.0-py3-none-any.whl (7.7 kB)
Using cached toml-0.10.2-py2.py3-none-any.whl (16 kB)
Using cached tqdm-4.66.2-py3-none-any.whl (78 kB)
Using cached wrapt-1.16.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (80 kB)
Using cached asttokens-2.4.1-py2.py3-none-any.whl (27 kB)
Using cached certifi-2024.2.2-py3-none-any.whl (163 kB)
Using cached charset_normalizer-3.3.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (142 kB)
Using cached executing-2.0.1-py2.py3-none-any.whl (24 kB)
Using cached googleapis_common_protos-1.62.0-py2.py3-none-any.whl (228 kB)
Using cached idna-3.6-py3-none-any.whl (61 kB)
Using cached parso-0.8.3-py2.py3-none-any.whl (100 kB)
Using cached ptyprocess-0.7.0-py2.py3-none-any.whl (13 kB)
Using cached six-1.16.0-py2.py3-none-any.whl (11 kB)
Using cached urllib3-2.2.1-py3-none-any.whl (121 kB)
Using cached fsspec-2024.2.0-py3-none-any.whl (170 kB)
Using cached importlib_resources-6.1.2-py3-none-any.whl (34 kB)
Using cached pure_eval-0.2.2-py3-none-any.whl (11 kB)
Using cached typing_extensions-4.10.0-py3-none-any.whl (33 kB)
Using cached wcwidth-0.2.13-py2.py3-none-any.whl (34 kB)
Using cached zipp-3.17.0-py3-none-any.whl (7.4 kB)
Building wheels for collected packages: promise
  Building wheel for promise (setup.py): started
  Building wheel for promise (setup.py): finished with status 'error'
  error: subprocess-exited-with-error
  
  × python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> [34 lines of output]
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "/tmp/pip-install-1tg86xmy/promise_7badce6d695f4e86844db09640a869d5/setup.py", line 28, in <module>
          setup(
        File "/home/sgk_ubuntu/.virtualenvs/r-keras/lib/python3.10/site-packages/setuptools/__init__.py", line 103, in setup
          return distutils.core.setup(**attrs)
        File "/home/sgk_ubuntu/.virtualenvs/r-keras/lib/python3.10/site-packages/setuptools/_distutils/core.py", line 172, in setup
          ok = dist.parse_command_line()
        File "/home/sgk_ubuntu/.virtualenvs/r-keras/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 475, in parse_command_line
          args = self._parse_command_opts(parser, args)
        File "/home/sgk_ubuntu/.virtualenvs/r-keras/lib/python3.10/site-packages/setuptools/dist.py", line 865, in _parse_command_opts
          nargs = _Distribution._parse_command_opts(self, parser, args)
        File "/home/sgk_ubuntu/.virtualenvs/r-keras/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 534, in _parse_command_opts
          cmd_class = self.get_command_class(command)
        File "/home/sgk_ubuntu/.virtualenvs/r-keras/lib/python3.10/site-packages/setuptools/dist.py", line 710, in get_command_class
          self.cmdclass[command] = cmdclass = ep.load()
        File "/home/sgk_ubuntu/.pyenv/versions/3.10.13/lib/python3.10/importlib/metadata/__init__.py", line 171, in load
          module = import_module(match.group('module'))
        File "/home/sgk_ubuntu/.pyenv/versions/3.10.13/lib/python3.10/importlib/__init__.py", line 126, in import_module
          return _bootstrap._gcd_import(name[level:], package, level)
        File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
        File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
        File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
        File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
        File "<frozen importlib._bootstrap_external>", line 883, in exec_module
        File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
        File "/home/sgk_ubuntu/.virtualenvs/r-keras/lib/python3.10/site-packages/wheel/bdist_wheel.py", line 27, in <module>
          from .macosx_libfile import calculate_macosx_platform_tag
        File "/home/sgk_ubuntu/.virtualenvs/r-keras/lib/python3.10/site-packages/wheel/macosx_libfile.py", line 43, in <module>
          import ctypes
        File "/home/sgk_ubuntu/.pyenv/versions/3.10.13/lib/python3.10/ctypes/__init__.py", line 8, in <module>
          from _ctypes import Union, Structure, Array
      ModuleNotFoundError: No module named '_ctypes'
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for promise
  Running setup.py clean for promise
Failed to build promise
ERROR: Could not build wheels for promise, which is required to install pyproject.toml-based projects
Error: Error installing package(s): 'scipy', 'pandas', 'Pillow', 'pydot', 'ipython', 'tensorflow_datasets', 'packaging'
> reticulate::py_config()
python:         /home/sgk_ubuntu/.virtualenvs/r-keras/bin/python
libpython:      /home/sgk_ubuntu/.pyenv/versions/3.10.13/lib/libpython3.10.so
pythonhome:     /home/sgk_ubuntu/.virtualenvs/r-keras:/home/sgk_ubuntu/.virtualenvs/r-keras
version:        3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0]
numpy:           [NOT FOUND]
keras:          [NOT FOUND]

NOTE: Python version was forced by import("keras")
> tensorflow::tf_config()
Valid installation of TensorFlow not found.

Python environments searched for 'tensorflow' package:
 /home/sgk_ubuntu/.pyenv/versions/3.10.13/bin/python3.10

Python exception encountered:
 Traceback (most recent call last):
  File "/home/sgk_ubuntu/R/x86_64-pc-linux-gnu-library/4.3/reticulate/python/rpytools/loader.py", line 119, in _find_and_load_hook
    return _run_hook(name, _hook)
  File "/home/sgk_ubuntu/R/x86_64-pc-linux-gnu-library/4.3/reticulate/python/rpytools/loader.py", line 93, in _run_hook
    module = hook()
  File "/home/sgk_ubuntu/R/x86_64-pc-linux-gnu-library/4.3/reticulate/python/rpytools/loader.py", line 117, in _hook
    return _find_and_load(name, import_)
ModuleNotFoundError: No module named 'tensorflow'


You can install TensorFlow using the install_tensorflow() function.
> reticulate::import("tensorflow")
Error in py_module_import(module, convert = convert) : 
  ModuleNotFoundError: No module named 'tensorflow'
Run `reticulate::py_last_error()` for details.
> library(tensorflow)
> reticulate::py_config()
python:         /home/sgk_ubuntu/.virtualenvs/r-keras/bin/python
libpython:      /home/sgk_ubuntu/.pyenv/versions/3.10.13/lib/libpython3.10.so
pythonhome:     /home/sgk_ubuntu/.virtualenvs/r-keras:/home/sgk_ubuntu/.virtualenvs/r-keras
version:        3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0]
numpy:           [NOT FOUND]
keras:          [NOT FOUND]

NOTE: Python version was forced by import("keras")
> tensorflow::tf_config()
Valid installation of TensorFlow not found.

Python environments searched for 'tensorflow' package:
 /home/sgk_ubuntu/.pyenv/versions/3.10.13/bin/python3.10

Python exception encountered:
 Traceback (most recent call last):
  File "/home/sgk_ubuntu/R/x86_64-pc-linux-gnu-library/4.3/reticulate/python/rpytools/loader.py", line 119, in _find_and_load_hook
    return _run_hook(name, _hook)
  File "/home/sgk_ubuntu/R/x86_64-pc-linux-gnu-library/4.3/reticulate/python/rpytools/loader.py", line 93, in _run_hook
    module = hook()
  File "/home/sgk_ubuntu/R/x86_64-pc-linux-gnu-library/4.3/reticulate/python/rpytools/loader.py", line 117, in _hook
    return _find_and_load(name, import_)
ModuleNotFoundError: No module named 'tensorflow'


You can install TensorFlow using the install_tensorflow() function.
> reticulate::import("tensorflow")
Error in py_module_import(module, convert = convert) : 
  ModuleNotFoundError: No module named 'tensorflow'
Run `reticulate::py_last_error()` for details.
> reticulate::py_last_error()
NULL
> sessionInfo()
R version 4.3.2 (2023-10-31)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 22.04.4 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.10.0 
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.10.0

locale:
 [1] LC_CTYPE=C.UTF-8       LC_NUMERIC=C           LC_TIME=C.UTF-8        LC_COLLATE=C.UTF-8     LC_MONETARY=C.UTF-8   
 [6] LC_MESSAGES=C.UTF-8    LC_PAPER=C.UTF-8       LC_NAME=C              LC_ADDRESS=C           LC_TELEPHONE=C        
[11] LC_MEASUREMENT=C.UTF-8 LC_IDENTIFICATION=C   

time zone: Europe/London
tzcode source: system (glibc)

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

other attached packages:
[1] tensorflow_2.15.0.9000

loaded via a namespace (and not attached):
 [1] base64enc_0.1-3        Matrix_1.6-3           lattice_0.22-5         reticulate_1.35.0.9000 magrittr_2.0.3        
 [6] rappdirs_0.3.3         remotes_2.4.2.1        glue_1.7.0             png_0.1-8              generics_0.1.3        
[11] lifecycle_1.0.4        cli_3.6.2              keras3_0.1.0.9000      grid_4.3.2             withr_3.0.0           
[16] zeallot_0.1.0          tfruns_1.5.2           compiler_4.3.2         rprojroot_2.0.4        here_1.0.1            
[21] rstudioapi_0.15.0      tools_4.3.2            whisker_0.4.1          Rcpp_1.0.12            rlang_1.1.3           
[26] jsonlite_1.8.8        

@t-kalinowski
Copy link
Member

t-kalinowski commented Mar 4, 2024

Thanks for reporting! I suspect this is an issue with Windows. Unfortunately, I don't have easy access to a Windows machine at the moment to reproduce.

Some comments and troubleshooting steps:

  • keras3::install_keras() will ignore miniconda by default, no need to call install_miniconda() or similar.
  • keras3::install_keras() is using a Python installed python via pyenv to create the r-keras venv.
Using Python: /home/sgk_ubuntu/.pyenv/versions/3.10.13/bin/python3.10
Creating virtual environment 'r-keras' ... 
+ /home/sgk_ubuntu/.pyenv/versions/3.10.13/bin/python3.10 -m venv /home/sgk_ubuntu/.virtualenvs/r-keras
Done!

This is good, but the first troubleshooting step would be to verify that Python installation at ~/.pyenv doesn't have any issues. You can try recreating it and looking at the printed output to see if there are any errors.

reticulate::install_python("3.10", force = TRUE)

If there are issues, you can try changing which python is used by install_keras()

keras3::install_keras(python_version = "/usr/bin/python3")

@sgkeith
Copy link

sgkeith commented Mar 9, 2024

Hi,

This is my output after re-installing python as you suggest:

> reticulate::install_python("3.10", force = TRUE)
+ /home/sgk_ubuntu/.local/share/r-reticulate/pyenv/bin/pyenv update
+ /home/sgk_ubuntu/.local/share/r-reticulate/pyenv/bin/pyenv install --force 3.10
Downloading Python-3.10.13.tar.xz...
-> https://www.python.org/ftp/python/3.10.13/Python-3.10.13.tar.xz
Installing Python-3.10.13...
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/sgk_ubuntu/.pyenv/versions/3.10.13/lib/python3.10/ctypes/__init__.py", line 8, in <module>
    from _ctypes import Union, Structure, Array
ModuleNotFoundError: No module named '_ctypes'
WARNING: The Python ctypes extension was not compiled. Missing the libffi lib?
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/sgk_ubuntu/.pyenv/versions/3.10.13/lib/python3.10/sqlite3/__init__.py", line 57, in <module>
    from sqlite3.dbapi2 import *
  File "/home/sgk_ubuntu/.pyenv/versions/3.10.13/lib/python3.10/sqlite3/dbapi2.py", line 27, in <module>
    from _sqlite3 import *
ModuleNotFoundError: No module named '_sqlite3'
WARNING: The Python sqlite3 extension was not compiled. Missing the SQLite3 lib?
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/sgk_ubuntu/.pyenv/versions/3.10.13/lib/python3.10/tkinter/__init__.py", line 37, in <module>
    import _tkinter # If this fails your Python may not be configured for Tk
ModuleNotFoundError: No module named '_tkinter'
WARNING: The Python tkinter extension was not compiled and GUI subsystem has been detected. Missing the Tk toolkit?
Installed Python-3.10.13 to /home/sgk_ubuntu/.pyenv/versions/3.10.13
[1] "/home/sgk_ubuntu/.pyenv/versions/3.10.13/bin/python3.10"

@sgkeith
Copy link

sgkeith commented Mar 9, 2024

...And now,

> keras3::install_keras(python_version = "/usr/bin/python3")
Virtual environment 'r-keras' removed.
Error in stop_no_virtualenv_starter(version = version, python = python) : 
  Suitable Python installation for creating a venv not found.
  Requested Python: /usr/bin/python3
  Requested version constraint: /usr/bin/python3
Please install Python with one of following methods:
- https://github.com/rstudio/python-builds/
- reticulate::install_python(version = '<version>')
- sudo apt install python3-venv

@sgkeith
Copy link

sgkeith commented Mar 9, 2024

Hi,

To solve the above issues with libffi, libsqlite3 and _tkinter, I then ran this code in WSL2:

sudo apt install libffi-dev
sudo apt install libsqlite3-dev
sudo apt install tk-dev
sudo apt install python3-venv

(sudo apt-get install python3-tk did no solve the _tkinter issue)

In rstudio-server, I then ran just:

keras3::install_keras()

library(tensorflow)
> tf$constant("Hello TensorFlow!")
tf.Tensor(b'Hello TensorFlow!', shape=(), dtype=string)

Success!

Thank you.

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

No branches or pull requests

7 participants