8080labs / ppscore

Predictive Power Score (PPS) in Python
MIT License
1.12k stars 168 forks source link

Problems installing ppscore via reticulate #8

Closed faltinl closed 4 years ago

faltinl commented 4 years ago

I want to use ppscore via R by means of reticulate (which I know from Keras in R; see link for details) and do the following in a fresh R session:

library(reticulate)
conda_list()

This shows the Python environments actually available on my computer:

1 Miniconda3 C:\Miniconda3\python.exe 2 r-reticulate C:\Miniconda3\envs\r-reticulate\python.exe

I choose use_condaenv("r-reticulate"), then py_install("ppscore", pip = TRUE), which produces:

Collecting package metadata (current_repodata.json): ...working... done Solving environment: ...working... done All requested packages already installed. Collecting ppscore Using cached ppscore-0.0.2.tar.gz (38 kB) Building wheels for collected packages: ppscore Building wheel for ppscore (setup.py): started Building wheel for ppscore (setup.py): finished with status 'done' Created wheel for ppscore: filename=ppscore-0.0.2-py2.py3-none-any.whl size=9634 sha256=6d04a943bc87ef27f697de2cedef048966e2a56f4f41667949d37f3f4fcebc2c Stored in directory: c:\users\lf\appdata\local\pip\cache\wheels\fd\39\a8\130eda2ee307e849923caf5b555b0d113ec7f7e8c7de731f9f Successfully built ppscore Installing collected packages: ppscore Successfully installed ppscore-0.0.2

Now, I want to import ppscore, ppscore <- import('ppscore') , which produces

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

Ok - so I do py_install(sklearn), which gives

Collecting package metadata (current_repodata.json): ...working... done Solving environment: ...working... done All requested packages already installed. Error in conda_install(envname, packages = packages, conda = conda, python_version = python_version, : Object 'sklearn' not found

This is somewhat surprising since when I do a pip list under Anaconda prompt I get

grafik

which clearly shows that package sklearn is present. And now I am at a loss what I could further do to successfully import and use (!) ppscore. I have to add that I am a complete newcomer to Python, so I am not at all familiar with Python environments.

I really would appreciate any useful hints - thanks in advance, Leo

8080labs commented 4 years ago

Hi Leo,

this might be due to the fact that there is an inconsistency with scikit-learn because you need to install scikit-learn via pip install scikit-learn but later you use it via import sklearn

For you, this might mean that you can try py_install(scikit-learn)

I hope this works, Florian

faltinl commented 4 years ago

Hi Florian,- thank you so much - that was it. Working like a charm. After some fiddling around with R/Py conversion, I even reproduced the heatmap of your example. Cheers, Leo

8080labs commented 4 years ago

Happy to hear that, Leo :)