conda skeleton cran uses wrong version of R - python

I am trying to package some R packages from CRAN to use in a conda environment because I am using a combination of Python and R packages for a bioinformatics pipeline. Because of other dependencies, I need to keep R at version 3.3
I made a brandnew environment with the version of Python and R I want:
$ conda create -n bioinfo python=3.6.3 r=3.3.2
There is no R installed in the root environment. Then I follow the instructions for conda skeleton:
(bioinfo)$ conda skeleton cran rootSolve
(bioinfo)$ conda skeleton cran rootSolve
(bioinfo)$ conda build r-rootsolve
For some reason, this keeps coming up with an R3.4 dependency, even though according to CRAN, the rootSolve package only needs R>=2.01! Where is this coming from??
The following NEW packages will be INSTALLED:
r-base: 3.4.2-haf99962_0
Though building the package does not actually change the version of R running in my environment, the package does not load. Any ideas, please?
R version 3.3.2 (2016-10-31) -- "Sincere Pumpkin Patch"
> library('rootSolve')
Error in dyn.load(file, DLLpath = DLLpath, ...) :
unable to load shared object '/usr/people/bioc1402/miniconda3/envs/bioinfo2/lib/R/library/rootSolve/libs/rootSolve.so':
/usr/people/bioc1402/miniconda3/envs/bioinfo2/lib/R/library/rootSolve/libs/rootSolve.so: undefined symbol: R_ExternalPtrAddrFn
In addition: Warning message:
package ‘rootSolve’ was built under R version 3.4.2
Error: package or namespace load failed for ‘rootSolve’

Apparently this was a bug, now fixed in conda-build 3.1.3,
https://github.com/conda/conda-build/issues/2562
Thanks conda team!
'conda build r-rootsolve --R=3.3.1' now works appropriately with the recipe generated by conda skeleton.

Related

No module found error for a downloaded package (sksparse.cholmod) and how to download a package from the internet to conda

I need to use the sksparse.chomod package however my pycharm does not let me install it as it can't seem to find it.
I found the sksparse package on github and downloaded it but I do not know how to add a package downloaded from the internet into a conda environment. So, my first question would be can you download a package from github and add it to your conda environment, and how do you do this?
As I did not know how to do the above I instead saved the package within my project and thought I could simply import sksparse.cholmod. However, the line in my code that says import sksparse.cholmod as sks has no errors with it, so I assumed that meant this was ok, but when I try to run my file I get this error:
import sksparse.cholmod as sks
ModuleNotFoundError: No module named 'sksparse.cholmod'
If I have downloaded the package into my project why can't it be found, yet there are no errors when importing?
The cholmod file is a pyx file which I've been told should not be a problem.
Please could anyone help, I am reasonably new to python and I am looking for a straight forward solution that won't be time consuming.
It was an issue with windows, I was able to fix this using the instructions on this link
https://github.com/EmJay276/scikit-sparse
We must follow these steps precisely:
(This was tested with a Anaconda 3 installation and Python 3.7)
Install these requirements in order:
'''
conda install -c conda-forge numpy - tested with v1.19.1
conda install -c anaconda scipy - tested with v1.5.0
conda install -c conda-forge cython - tested with v0.29.21
conda install -c conda-forge suitesparse - tested with v5.4.0
'''
Download Microsoft Build Tools for C++ from https://visualstudio.microsoft.com/de/visual-cpp-build-tools/ (tested with 2019, should work with 2015 or newer)
Install Visual Studio Build Tools
Choose Workloads
Check "C++ Buildtools"
Keep standard settings
Run ''' pip install git+https://github.com/EmJay276/scikit-sparse '''
Test ''' from sksparse.cholmod import cholesky '''
Use all the versions stated for numpy etc, however with scipy I installed the latest version and it worked fine.

How can I install gekko package using R reticulate?

I can't install gekko package via R reticulate. My R version is 3.4.4 and my Python version is 3.8.8 and I use Gekko in Python without problems. So I tried to install on R in these two ways I know:
py_install("gekko")
reticulate::conda_install("my_conda_environment", "gekko")
However in both cases I receive the same error bellow.
PackagesNotFoundError: The following packages are not available from current channels:
gekko
Current channels:
https://conda.anaconda.org/root/win-64
https://conda.anaconda.org/root/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
I didn't find other alternatives in the Anaconda documentation. How can I fix this?
Edit: I solved my problem based on the references in John Hedengren's answer and reticulate docs. For that, I needed to create a new environment to specify the Python version and packages using the following code in R:
reticulate::py_install(
packages = c(
"numpy",
"pandas", # Or another packages that you need
"gekko"
),
envname = "r-gekko",
method = "conda", # On Windows, the 'conda' method is always used
python_version = "3.8.8",
pip = TRUE # It's mandatory to install gekko
)
Gekko is available from pypi.org with pip install gekko and is not available with the conda package manager with conda install gekko. Here is more information on how to install Python packages with pip. You likely already know this because you are using gekko in Python but I've included it here for some background in case others need it.
Two potential problems are:
There are multiple Python versions installed and gekko is not installed for the version that is used with R.
Reticulate is not using PyPi repositories to install gekko. Here is additional information on managing the source (either Conda or PyPi) to retrieve the packages.
I'm not familiar with R but there are others that have similar questions such as:
Error when installing package from PyPi in R using reticulate and Anaconda3
reticulate conda_install fails to install package from PyPI
Error while installing Python module in R via reticulate
How to install packages in conda that are not available in anaconda
A more general answer for help in similar cases:
Install gekko and other packages in a new environment in R.
reticulate::py_install(
packages = c(
"gekko",
"other_package==x.x.x", # It's possible to specify the package version
...
),
envname = "new_env",
method = "conda", # For Windows
python_version = "3.x.x",
pip = TRUE
)
Call reticulate package using the new environment.
Sys.setenv(RETICULATE_PYTHON = "/Users/user_name/anaconda#/envs/new_env/python.exe")
library(reticulate)
Run your Python script with gekko in R.
source_python("path/script.py")

Error while running azuremlsdk::install_azureml() in R

I'm trying to load an existing azure workspace in RStudio Azure Compute Instance like it's shown in this link: https://azure.github.io/azureml-sdk-for-r/. But, after installing azuremlsdk package when I'm running this code azuremlsdk::install_azureml(). I'm getting this error :
Attempting uninstall: certifi  Found existing installation: certifi2016.9.26ERROR: Cannot uninstall 'certifi'. It is a distutilsinstalled project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.Error: Error installing package(s): 'azureml-sdk==1.10.0', 'numpy', 'pandas'
By referring to this link : https://learn.microsoft.com/en-us/azure/machine-learning/how-to-troubleshoot-environments; I tried to fix this error by running conda remove certifi through terminal of that Compute Instance & Jupyter Notebook of that Compute Instance. But, no luck.
Does anyone have any experience in resolving this issue. Please help.
Azure ML has issues with Python versions and its dependency packages, make sure you are using Python package of 3.5 to 3.8 while installing these.
While installing azureml it will search for all the dependency packages and will install all of them, in this process there will be the version issues, like pandas, numpy.. with different pip versions.
From your stack trace looks like the error is happening when we install the packages like pandas numpy etc along with azureml-train-automl-client package so try to install them before hand by checking its versions which are dependent with you python versions packages.
Check the Azure ML documentation for installation of Azure ML Additional packages.
If you investigate them azureml-train-automl requires somes data science packages including pandas, numpy, and scikit-learn.
Kindly follow below commands for conda environment:
pip install azureml-train-automl
pip install --upgrade azureml-train-automl
pip install show azureml-train-automl
It seems that the Python SDK installation conflicts with itself when using Python 3.6 (the default). I was able to install the SDK for Python 3.7:
azuremlsdk::install_azureml(conda_python_version = '3.7')

R installation not finding anaconda packages

I was trying to install some packages in R and I have run into an error:
Error: package or namespace load failed for ‘leiden’:
.onAttach failed in attachNamespace() for 'leiden', details:
call: py_module_import(module, convert = convert)
error: ModuleNotFoundError: No module named 'pandas'
This is strange to me because I definitely have pandas:
$ conda list | grep pandas
pandas 1.0.1 py37h0573a6f_0
Also which python seems to give me my anaconda installation:
/home/usrname/anaconda3/bin/python
I am installing these packages on WSL (Windows Subsystem for Linux) Ubuntu.
Any advice appreciated.
I ended up finding another issue with a similar problem. Turns out I needed to activate the conda r-reticulate environment.
Take a look at a similar question here: Python in R - Error: could not find a Python environment for /usr/bin/python

CX_Oracle for python, under Anaconda is not installing

Anaconda keeps telling me that cx_oracle needs python 3.4.
My conda version is 4.3.17
This is after I used the cx_Oracle-5.3-11g.win-amd64-py3.5-2.exe installer. which is supposed to be used for Python 3.5.
conda install -c anaconda cx_oracle=5.2
Fetching package metadata ...............
Solving package specifications: .
UnsatisfiableError: The following specifications were found to be in conflict:
- cx_oracle 5.2* -> python 3.4*
- python 3.5*
Use "conda info <package>" to see the dependencies for each package.
I'm doing something stupid, but I'm not sure what. yet.
ideas?
hints?
The error's telling you that the cx_oracle package you're trying to install depends on Python 3.4 b/c that's the currently available build of cx_oracle on the anaconda channel.
If you search for cx_oracle on anaconda.org, you'll see a list of available builds on several other channels, and can look for one that meets your reqs (namely v5.2, Python 3.5, win64). Doesn't look like there's one that meets that exact set of reqs, but there are a few v5.21 & v5.3 builds available. If that's close enough, then installing from say, the amodig channel may get you going: conda install -c amodig cx_oracle=5.2.1

Categories