Error while installing Python module in R via reticulate - python

I am using R and I want to use a function I wrote in Python which needs to import:
from sklearn.neighbors.kde import KernelDensity
I am trying to use the following code:
library(reticulate)
py_install("scikit-learn.neighbors.kde")
I have already installed sklearn with:
py_install("scikit-learn")
Also trying
py_install("sklearn.neighbors.kde")
does not work.
I get the following error/log:
Solving environment: ...working... failed with initial frozen solve. Retrying with flexible solve.
Collecting package metadata (repodata.json): ...working... done
Solving environment: ...working... failed with initial frozen solve. Retrying with flexible solve.
PackagesNotFoundError: The following packages are not available from current channels:
- scikit-learn.neighbors.kde
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.
Error: one or more Python packages failed to install [error code 1]
Any suggestion on how to fix this?

The module is KernelDensity not kde. If sklearn is installed, below should work:
library(reticulate)
sklearn = import("sklearn")
kde = sklearn$neighbors$KernelDensity
kde
<class 'sklearn.neighbors._kde.KernelDensity'>
X = matrix(rnorm(20),10,1)
kde = kde(kernel="gaussian")$fit(X)
kde$score_samples(X)
[1] -1.479458 -1.603451 -1.338018 -1.465263 -1.655933 -1.463628 -1.340137
[8] -1.856085 -1.374666 -1.478621

Related

Installing CERN ROOT in anaconda environment- packages are not available from current channels:

I am attempting to install CERNS ROOT in anaconda, for use of pyRoot. (I am using conda 4.10.3)
I have set up a new environment with python 2.7, because I believe I read somewhere that ROOT does not work well with python 3. After installing python to the new environment and activating it, I have added conda-forge to the current channels and attempted to install the following:
https://anaconda.org/conda-forge/root-dependencies
Using:
conda install -c conda-forge root-dependencies
This however returned the following:
(pyRoot) C:\Users\George>conda install -c conda-forge root-dependencies
Collecting package metadata (current_repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Collecting package metadata (repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
PackagesNotFoundError: The following packages are not available from current channels:
- root-dependencies
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/free/win-64
- https://repo.anaconda.com/pkgs/free/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.
I am not sure why this is not working, as I am fairly sure the root-dependencies are available on the conda-forge channel as per the link.
I have tried the following:
SET CONDA_RESTORE_FREE_CHANNEL=1
Just in case it was part of the free channel that may have been dropped, but I still get the same error.
Any ideas are appreciated :)
The package is not built for win-64 platform, which is what OP channel configuration indicates is being used. Consider WSL2 or Docker (ROOT Project provides pre-built images).
If you would like Conda Forge to build a Windows version, submit an Issue on the feedstock. Just be aware that ROOT Project itself only has beta support for Windows natively, so it's likely not a trivial task.

ModuleNotFoundError: No module named 'sklearn' python

For some reason my Python (Spyder) is not recognising sklearn library and pyodbc library
2 weeks ago everything was ok,
but not sure what happened that I am getting this error
ModuleNotFoundError: No module named 'sklearn'
and
ModuleNotFoundError: No module named 'pyodbc'
When I try
pip install sklearn
I get
pip install sklearn
Note: you may need to restart the kernel to use updated packages.
'C:\Program' is not recognized as an internal or external command,
operable program or batch file.
I restarted my computer still the same !
Any idea how to fix this?
Edit
When I try to pip install it from Anaconda Poweshell Promopt
(base) PS C:\Users\ASMGX> conda install sklearn
Collecting package metadata (current_repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Collecting package metadata (repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
PackagesNotFoundError: The following packages are not available from current channels:
- sklearn
Current channels:
- 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.
i know this may not be the best solution.
but it worked for me.
to uninstall Anaconda and Python and re-install them again!

Error when installing package from PyPi in R using reticulate and Anaconda3

I am a new user and I'm trying to install a Python package called capiq_excel in R using reticulate. I have anaconda3 as well as S&P Capital IQ's excel plug installed on my system (capiq_excel documentation can be found at https://nickderobertis.github.io/capiq-excel-downloader-py/tutorial.html#install)
So far, I've set the path to Python in my R system as follows
library(reticulate)
use_python("C:/Users/user/anaconda3/python.exe",
required = T)
py_config()
which provides the following output
python: C:/Users/user/anaconda3/python.exe
libpython: C:/Users/user/anaconda3/python38.dll
pythonhome: C:/Users/user/anaconda3
version: 3.8.3 (default, Jul 2 2020, 17:30:36) [MSC v.1916 64 bit (AMD64)]
Architecture: 64bit
numpy: C:/Users/user/anaconda3/Lib/site-packages/numpy
numpy_version: 1.18.5
NOTE: Python version was forced by use_python function
however, when I try to install the capiq_excel package using the following line
py_install('capiq_excel')
I get the following error
Collecting package metadata (current_repodata.json): ...working... done
Solving environment: ...working... failed with initial frozen solve. Retrying with flexible solve.
Collecting package metadata (repodata.json): ...working... done
Solving environment: ...working... failed with initial frozen solve. Retrying with flexible solve.
PackagesNotFoundError: The following packages are not available from current channels:
- capiq_excel
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.
Could this be because the capiq_excel package is available on PyPi while I'm using an anaconda framework? What is the best way to approach this issue?
TIA!

Can't install Pygame using conda

I was trying to install Pygame module using conda.
I used this command:
conda install pygame
It gave me the following error:
Collecting package metadata (current_repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Collecting package metadata (repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
PackagesNotFoundError: The following packages are not available from current channels:
- pygame
Current channels:
- 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.
Then I used the following command:
conda install -c cogsci pygame
Output:
Collecting package metadata (current_repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Solving environment: failed with repodata from current_repodata.json, will retry with next repodata source.
Collecting package metadata (repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Solving environment: \
Found conflicts! Looking for incompatible packages.
This can take several minutes. Press CTRL-C to abort.
Examining python=3.7: 100%|██████████████████████████████████████████████████████████████| 2/2 [00:00<00:00, 11.12it/s]-failed
UnsatisfiableError: The following specifications were found
to be incompatible with the existing python installation in your environment:
Specifications:
- pygame -> python[version='2.7.*|3.5.*']
Your python: python=3.7
If python is on the left-most side of the chain, that's the version you've asked for.
When python appears to the right, that indicates that the thing on the left is somehow
not available for the python version you are constrained to. Note that conda will not
change your python version to a different minor version unless you explicitly specify
that.
I have installed different modules using conda install like tensorflow, numpy, pandas,matplotlib and they are all working but it is giving me an error in pygame.
How do I fix it and install Pygame?
The pygame package at cogsci is 4 years old and only compatible with python2.7. If you want the latest version use pip install pygame. Personnally I use the conda package at evindunn which is only available for linux-64

Having Trouble Installing Pillow in PyCharm using Anaconda enviroment

I am trying to install pillow for a project I am doing using PyCharm and Anaconda and having some trouble... Basically, when I try to install pillow in my anaconda environment it says that pillow is already downloaded. However, when I am running code in PyCharm it says that pillow is not installed and asks me if I would like to install it. I click install package and this is the error I get:
Collecting package metadata (current_repodata.json): ...working... done
Solving environment: ...working... failed with initial frozen solve. Retrying with flexible solve.
Collecting package metadata (repodata.json): ...working... done
Solving environment: ...working... failed with initial frozen solve. Retrying with flexible solve.
PackagesNotFoundError: The following packages are not available from current channels:
- pil
Current channels:
- 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
- https://conda.anaconda.org/conda-forge/win-64
- https://conda.anaconda.org/conda-forge/noarch
- https://conda.anaconda.org/sunpy/win-64
- https://conda.anaconda.org/sunpy/noarch
- https://conda.anaconda.org/cctbx/win-64
- https://conda.anaconda.org/cctbx/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.
I have tried using different channels using:
conda config --append channels (whatever channel)
The channels I have tried using are sunpy and cctbx
I am a bit confused with this so any help is greatly appreciated. Thanks!
Turns out I just need to use pillow instead of pil. Seems like a simple little mistake but dang... really goofed me up.

Categories

Resources