Skip to content

Installing sklearn doesn't work with either py_install or conda_install #623

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

Open
dshelldhillon opened this issue Oct 25, 2019 · 11 comments

Comments

@dshelldhillon
Copy link

dshelldhillon commented Oct 25, 2019

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.
@kevinushey
Copy link
Collaborator

You probably want py_install(pip = TRUE).

@dshelldhillon
Copy link
Author

I tried it - a different error now below

Collecting sklearn
Collecting scikit-learn (from sklearn)
  Using cached https://files.pythonhosted.org/packages/d6/9e/6a42486ffa64711fb868e5d4a9167153417e7414c3d8d3e0d627cf391e1e/scikit_learn-0.21.3-cp37-cp37m-win_amd64.whl
Collecting scipy>=0.17.0 (from scikit-learn->sklearn)
  Using cached https://files.pythonhosted.org/packages/50/eb/defa40367863304e1ef01c6572584c411446a5f29bdd9dc90f91509e9144/scipy-1.3.1-cp37-cp37m-win_amd64.whl
Collecting numpy>=1.11.0 (from scikit-learn->sklearn)
  Using cached https://files.pythonhosted.org/packages/e9/dd/a177f27765b1e5f94fa879cbeef61f8807086371d0b6aa232b836d38b78b/numpy-1.17.3-cp37-cp37m-win_amd64.whl
Collecting joblib>=0.11 (from scikit-learn->sklearn)
  Using cached https://files.pythonhosted.org/packages/8f/42/155696f85f344c066e17af287359c9786b436b1bf86029bb3411283274f3/joblib-0.14.0-py2.py3-none-any.whl
Installing collected packages: numpy, scipy, joblib, scikit-learn, sklearn
ERROR: Could not install packages due to an EnvironmentError: [WinError 5] Access is denied: 'C:\\Users\\dilsher.dhillon\\AppData\\Local\\Continuum\\miniconda3\\envs\\r-reticulate\\Lib\\site-packages\\numpy\\core\\_multiarray_tests.cp37-win_amd64.pyd'
Consider using the `--user` option or check the permissions.

@dshelldhillon
Copy link
Author

Is there a way I can add the --user argument to the py_install ?

@kevinushey
Copy link
Collaborator

I wonder if that error is occurring because py_install() is trying to reinstall numpy after it's already been loaded?

I'll think about how we could allow for addition arguments to be passed during the installation process.

@kevinushey kevinushey reopened this Oct 28, 2019
@seriph78
Copy link

I don't know if it can help, but I solved using:

py_install("scikit-learn")

@RameezRoshan
Copy link

I don't know if it can help, but I solved using:

py_install("scikit-learn")

Great !! It works!

@ebalmas
Copy link

ebalmas commented 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
Copy link
Member

@ebalmas what is the error you are seeing?
Running py_install("scikit-learn") locally succeeds without error for me.

@ebalmas
Copy link

ebalmas commented 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.

  Here is how to fix this error in the main use cases:
  - use 'pip install scikit-learn' rather than 'pip install sklearn'
  - replace 'sklearn' by 'scikit-learn' in your pip requirements files
    (requirements.txt, setup.py, setup.cfg, Pipfile, etc ...)
  - if the 'sklearn' package is used by one of your dependencies,
    it would be great if you take some time to track which package uses
    'sklearn' instead of 'scikit-learn' and report it to their issue tracker
  - as a last resort, set the environment variable
    SKLEARN_ALLOW_DEPRECATED_SKLEARN_PACKAGE_INSTALL=True to avoid this error
  
  More information is available at
  https://github.com/scikit-learn/sklearn-pypi-package
  [end of output]

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
Copy link

ebalmas commented 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
Copy link
Member

t-kalinowski commented Jan 29, 2024

once I try to run a python code that has it as a dependency, it asks again for 'sklearn'

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.,

reticulate::py_install(
  "sklearn", pip = TRUE, 
  pip_options = "--index-url https://packagemanager.posit.co/pypi/2023-08-01/simple"
)

https://packagemanager.posit.co/client/#/repos/pypi/setup?snapshot=2024-01-29

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

6 participants