Open
Description
py_install and conda_install worked for pandas but for sklearn, it throws me an error. The whole error doesn't show up in reprex which I've copied and pasted from the console directly.
library(reticulate)
py_install("sklearn")
#> Error: Error 1 occurred installing packages into conda environment r-reticulate
conda_install("r-reticulate", "sklearn")
#> Error: Error 1 occurred installing packages into conda environment r-reticulate
sessionInfo()
#> R version 3.6.1 (2019-07-05)
#> Platform: x86_64-w64-mingw32/x64 (64-bit)
#> Running under: Windows 10 x64 (build 16299)
#>
#> Matrix products: default
#>
#> locale:
#> [1] LC_COLLATE=English_United States.1252
#> [2] LC_CTYPE=English_United States.1252
#> [3] LC_MONETARY=English_United States.1252
#> [4] LC_NUMERIC=C
#> [5] LC_TIME=English_United States.1252
#>
#> attached base packages:
#> [1] stats graphics grDevices utils datasets methods base
#>
#> other attached packages:
#> [1] reticulate_1.13.0-9003
#>
#> loaded via a namespace (and not attached):
#> [1] Rcpp_1.0.2 digest_0.6.21 rappdirs_0.3.1 jsonlite_1.6
#> [5] magrittr_1.5 evaluate_0.14 highr_0.8 rlang_0.4.0
#> [9] stringi_1.4.3 rmarkdown_1.16 tools_3.6.1 stringr_1.4.0
#> [13] xfun_0.10 yaml_2.2.0 compiler_3.6.1 htmltools_0.4.0
#> [17] knitr_1.25
Error copied from console
Collecting package metadata (current_repodata.json): ...working... done
Solving environment: ...working... failed with current_repodata.json, will retry with next repodata source.
Collecting package metadata (repodata.json): ...working... done
Solving environment: ...working... failed
PackagesNotFoundError: The following packages are not available from current channels:
- sklearn
Current channels:
- https://conda.anaconda.org/conda-forge/win-64
- https://conda.anaconda.org/conda-forge/noarch
- https://repo.anaconda.com/pkgs/main/win-64
- https://repo.anaconda.com/pkgs/main/noarch
- https://repo.anaconda.com/pkgs/r/win-64
- https://repo.anaconda.com/pkgs/r/noarch
- https://repo.anaconda.com/pkgs/msys2/win-64
- https://repo.anaconda.com/pkgs/msys2/noarch
To search for alternate channels that may provide the conda package you're
looking for, navigate to
https://anaconda.org
and use the search bar at the top of the page.
Activity
kevinushey commentedon Oct 25, 2019
You probably want py_install(pip = TRUE).
dshelldhillon commentedon Oct 26, 2019
I tried it - a different error now below
dshelldhillon commentedon Oct 26, 2019
Is there a way I can add the
--user
argument to the py_install ?kevinushey commentedon Oct 28, 2019
I wonder if that error is occurring because
py_install()
is trying to reinstallnumpy
after it's already been loaded?I'll think about how we could allow for addition arguments to be passed during the installation process.
seriph78 commentedon Mar 20, 2020
I don't know if it can help, but I solved using:
py_install("scikit-learn")
RameezRoshan commentedon Sep 13, 2020
Great !! It works!
ebalmas commentedon Jan 26, 2024
I also tried all your tricks but I still cannot install sklearn. I'm using R 4.3.1 python 3.12.1 on a Mac OS Ventura 13.5 (not sure the mac is a problem). I'm a really new user of python.
t-kalinowski commentedon Jan 26, 2024
@ebalmas what is the error you are seeing?
Running
py_install("scikit-learn")
locally succeeds without error for me.ebalmas commentedon Jan 26, 2024
Collecting sklearn
Using cached sklearn-0.0.post12.tar.gz (2.6 kB)
Preparing metadata (setup.py): started
Preparing metadata (setup.py): finished with status 'error'
error: subprocess-exited-with-error
× python setup.py egg_info did not run successfully.
│ exit code: 1
╰─> [15 lines of output]
The 'sklearn' PyPI package is deprecated, use 'scikit-learn'
rather than 'sklearn' for pip commands.
note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed
× Encountered error while generating package metadata.
╰─> See above for output.
note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
Error: Error installing package(s): 'sklearn'
ebalmas commentedon Jan 26, 2024
I also tried to install py_install("scikit-learn") and works, but once I try to run a python code that has it as a dependency, it asks again for 'sklearn'
t-kalinowski commentedon Jan 29, 2024
It seems you have some legacy code that either needs to be updated, or you need to roll-back your environment to what the legacy code requires. You'll probably need an older version of Python, and hopefully you'll have a
requirements.txt
file.You can point pip at the posit package manager with a snapshot date, which will install the versions of packages that were available in pypi on a given date. E.g.,
https://packagemanager.posit.co/client/#/repos/pypi/setup?snapshot=2024-01-29