Problem in install R using conda on a server cluster - r

I tried to install R on cluster server using conda. Conda created environment successfully, but it can not install R. It gives the following error message:
-bash-4.2$ conda install -c conda-forge r-base=4.2.0
Collecting package metadata (current_repodata.json): failed
# >>>>>>>>>>>>>>>>>>>>>> ERROR REPORT <<<<<<<<<<<<<<<<<<<<<<
Traceback (most recent call last):
File "/opt/ohpc/pub/anaconda3/lib/python3.8/site-packages/conda/gateways/connection/session.py", line 52, in __call__
return cls._thread_local.session
AttributeError: '_thread._local' object has no attribute 'session'
active environment : /home/zwei/bartsfm
active env location : /home/zwei/bartsfm
shell level : 3
user config file : /home/zwei/.condarc
populated config files : /home/zwei/.condarc
conda version : 4.8.3
conda-build version : 3.18.11
python version : 3.8.3.final.0
virtual packages : __glibc=2.17
base environment : /opt/ohpc/pub/anaconda3 (read only)
channel URLs : https://conda.anaconda.org/conda-forge/linux-64
https://conda.anaconda.org/conda-forge/noarch
https://repo.anaconda.com/pkgs/main/linux-64
https://repo.anaconda.com/pkgs/main/noarch
https://repo.anaconda.com/pkgs/r/linux-64
https://repo.anaconda.com/pkgs/r/noarch
package cache : /home/zwei/conda/pkgs
envs directories : /home/zwei/bartsfm
/home/zwei/.conda/envs
/opt/ohpc/pub/anaconda3/envs
platform : linux-64
user-agent : conda/4.8.3 requests/2.24.0 CPython/3.8.3 Linux/3.10.0-1160.76.1.el7.x86_64 Linux/unknown glibc/2.17
UID:GID : 1620:1546
netrc file : None
offline mode : False
...
An unexpected error has occurred. Conda has prepared the above report.
Upload successful.
I guess I mess up the environment variables for conda. Could any one help? Many thanks.

Related

Cannot find python version when installing the R interface to keras

I am trying to intsall the r interface to keras/tensoflow in R studio following the code bellow:
`install.packages('devtools')
devtools::install_github("rstudio/keras")
devtools::install_github("rstudio/tensorflow")
library(tensorflow)
install_tensorflow(version = "2.8.0")
library(keras)
install_keras()
reticulate::use_condaenv("anaconda3", required = TRUE)`
All things are Ok until install_tensorflow(version = "2.8.0"), the r studio says
No non-system installation of Python could be found. Would you like to download and install Miniconda?
I choose because I want to use the python of my our anaconda environment. But when finishing this command line, it has a warning message
Warning message:
In system2(conda, c("run", in_env, run_args, shQuote(cmd), args),:
running command '"C:/Users/jinhu/anaconda3/condabin/conda.bat"
run --prefix "C:\Users\jinhu\anaconda3" --no-capture-output "python" -c "import os;
print(os.environ['PATH'])"' had status 1
In addition, when I input the py_config function to see the available python version, it output:
Error in Sys.setenv(PATH = new_path) : wrong length for argument In addition: Warning message: In system2(conda, c("run", in_env, run_args, shQuote(cmd), args), : running command '"C:/Users/jinhu/anaconda3/condabin/conda.bat" run --prefix "C:\Users\jinhu\anaconda3\envs\r-reticulate" --no-capture-output "python" -c "import os; print(os.environ['PATH'])"' had status 1
below is my conda list:
conda_list()
name python
base C:\\Users\\jinhu\\anaconda3/python.exe
pytorch C:\\Users\\jinhu\\anaconda3\\envs\\pytorch/python.exe
r-reticulate C:\\Users\\jinhu\\anaconda3\\envs\\r-reticulate/python.exe
tensorflow C:\\Users\\jinhu\\anaconda3\\envs\\tensorflow/python.exe
Here is my conda verson:
(base) C:\Users\jinhu>conda info
active environment : base
active env location : C:\Users\jinhu\anaconda3
shell level : 1
user config file : C:\Users\jinhu\.condarc
populated config files : C:\Users\jinhu\.condarc
conda version : 4.10.3
conda-build version : 3.21.6
python version : 3.9.7.final.0
virtual packages : __cuda=11.4=0
__win=0=0
__archspec=1=x86_64
base environment : C:\Users\jinhu\anaconda3 (writable)
conda av data dir : C:\Users\jinhu\anaconda3\etc\conda
conda av metadata url : None
channel URLs : 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
package cache : C:\Users\jinhu\anaconda3\pkgs
C:\Users\jinhu\.conda\pkgs
C:\Users\jinhu\AppData\Local\conda\conda\pkgs
envs directories : C:\Users\jinhu\anaconda3\envs
C:\Users\jinhu\.conda\envs
C:\Users\jinhu\AppData\Local\conda\conda\envs
platform : win-64
user-agent : conda/4.10.3 requests/2.26.0 CPython/3.9.7 Windows/10 Windows/10.0.22000
administrator : False
netrc file : None
offline mode : False
Also when I try use_condaenv( "r-reticulate"), it shows:
`Error in Sys.setenv(PATH = new_path) : wrong length for argument In addition: Warning message: In system2(conda, c("run", in_env, run_args, shQuote(cmd), args), : running command '"C:/Users/jinhu/anaconda3/condabin/conda.bat" run --prefix "C:\Users\jinhu\anaconda3\envs\r-reticulate" --no-capture-output "python" -c "import os; print(os.environ['PATH'])"' had status 1`
I think the question is new-created r-reticulate environment cannot find the available python, what should I do to solve it?

Update R in anaconda

My first idea was to get R version 4 on my rstudio beside anaconda
My ADD brain then fought getting the newest version of R in my base environment
I have before created new conda environments with different versions of R without a problem
Now I start R in my Ubuntu 18.04.5 and get:
R version 3.5.1
I download the newest version of R (should be 4.0.5) with conda install -c conda-forge r-base
I restart the computer but I am stuck in R version 3.5.1
I do conda update -n base conda and nothing changes
conda config --show-sources
==> /home/notandi/anaconda3/.condarc <==
channels:
- conda-forge
- bioconda
- defaults
==> /home/notandi/.condarc <==
channels:
- bioconda
- defaults
conda info:
active environment : base
active env location : /home/notandi/anaconda3
shell level : 1
user config file : /home/notandi/.condarc populated config files : /home/notandi/anaconda3/.condarc
/home/notandi/.condarc
conda version : 4.10.1
conda-build version : 3.20.2
python version : 3.7.7.final.0
virtual packages : __linux=4.15.0=0
__glibc=2.27=0
__unix=0=0
__archspec=1=x86_64
base environment : /home/notandi/anaconda3 (writable)
conda av data dir : /home/notandi/anaconda3/etc/conda conda av metadata url : https://repo.anaconda.com/pkgs/main
channel URLs : https://conda.anaconda.org/bioconda/linux-64
https://conda.anaconda.org/bioconda/noarch
https://repo.anaconda.com/pkgs/main/linux-64
https://repo.anaconda.com/pkgs/main/noarch
https://repo.anaconda.com/pkgs/r/linux-64
https://repo.anaconda.com/pkgs/r/noarch
https://conda.anaconda.org/conda-forge/linux-64
https://conda.anaconda.org/conda-forge/noarch
package cache : /home/notandi/anaconda3/pkgs
/home/notandi/.conda/pkgs
envs directories : /home/notandi/anaconda3/envs
/home/notandi/.conda/envs
platform : linux-64
user-agent : conda/4.10.1 requests/2.25.1 CPython/3.7.7 Linux/4.15.0-143-generic ubuntu/18.04.5 glibc/2.27
UID:GID : 1000:1000
netrc file : None
offline mode : False
What does the Singularity want from me?
The best solution for me is to update the place where Anaconda is looking for the packages. To do that:
Open Anaconda
Go to Environments and select your desired environment
Lets add a new channel to look for updated packages: button Channels --> click Add --> type conda-forge --> enter --> click Update Channels
Lets wait until Anaconda update packages list and look for the R package (now it should show you the last version) and either update it or installed it from crash.

Error: package or namespace load failed for 'rjags'

In one of my conda environments in terminal, I am able to successfully install the package 'rjags'. However, when I run R within that environment and run library(rjags), I get the following error:
Loading required package: coda Error: package or namespace load failed for 'rjags': .onLoad failed in loadNamespace() for 'rjags', details: call: dyn.load(file, DLLpath = DLLpath, ...) error: unable to load shared object '/user-path/anaconda3/envs/r-env/lib/R/library/rjags/libs/rjags.so': /user-path/anaconda3/envs/r-env/lib/R/library/rjags/libs/rjags.so: undefined symbol: _ZN4jags7Console10setRNGnameERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEj In addition: Warning messages: 1: package 'rjags' was built under R version 3.6.3 2: package 'coda' was built under R version 3.6.3
If I install and with R, perform library(rjags) in another environment or in the base environment, everything works fine. I am wondering what this error message means and how to resolve it.
The output of conda list "^(libstdcxx-ng|r-base|r-coda|jags|r-rjags)$" is:
# packages in environment at /user-path/anaconda3/envs/r-env:
#
# Name Version Build Channel
jags 4.3.0 h26a2512_0 conda-forge
libstdcxx-ng 9.1.0 hdf63c60_0
r-base 3.6.1 h9bb98a2_1
r-coda 0.19_3 r36h6115d3f_2 conda-forge
r-rjags 4_10 r36h0357c0b_1 conda-forge
Channel Mixing Gone Wrong
I suspect that the error is due to mixing of Conda Forge and Anaconda packages. The organizations use different build stacks and so the dynamic libraries they build can end up having different internal definitions (for details, see this Issue on the Conda Forge repository). For example, in this case rjags.so is built to look for a symbol in the libraries that it links to, but it fails to find it in the Anaconda builds. Unfortunately, it links to too many (check with ldd rjags.so) for me to track down which specifically is causing the issue.
However, you still have a some options to get rjags working, just not a precision fix. In all cases the solution is to prioritize the conda-forge channel.
Option 1: Create a new dedicated env
If you don't actually need rjags in this specific env, then create a new one with the packages you will need. However, when doing so, make conda-forge the priority channel over defaults:
conda create -n rjags_env -c conda-forge r-rjags
conda activate rjags_env
conda config --env --add channels conda-forge
Option 2: Recreate env using Conda Forge
If your goal is to add rjags to the existing env, and you can't figure out the specific package that needs to change, you instead could recreate the env with the updated priority.
First, export the env to a YAML like
conda env export -n r-env --no-builds > rjags_env.yaml
Next, edit this file so that the channels section reads:
name: rjags_env
channels:
- conda-forge
- defaults
dependencies:
Finally create a new version of the env with
conda env create -f rjags_env.yaml -n rjags_env
Additional notes
I also looked into using the --update-deps flag with conda install, but that forces the env to update to R v4.0.1 and breaks the r-coda install.

Error while running R from commandlne ubuntu : error while loading shared libraries: libpcre.so.1: cannot open shared object file

Hi I am running R on Ubuntu : Getting this error:
/home/user/anaconda3/lib/R/bin/exec/R: error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory
I have installed anaconda recently, I have tried
$echo $LD_LIBRARY_PATH
It shows nothing. I also tried
$sudo find / lib | grep libpcre.so.1
I want to run R on Ubuntu. It was running fine before; any hints?

Error in installing car package in R

While installing "car" package in Rstudio in Ubuntu, I faced an error saying that dependencies "nloptr","lme4" and one more, are not installed.
So I started installing "nloptr" but I faced this error-
configure: Need to download and build NLopt
trying URL 'http://ab-initio.mit.edu/nlopt/nlopt-2.4.2.tar.gz'
Error in download.file(url = "http://ab-initio.mit.edu/nlopt/nlopt-
2.4.2.tar.gz", :
cannot open URL 'http://ab-initio.mit.edu/nlopt/nlopt-2.4.2.tar.gz'
Execution halted
/bin/tar: This does not look like a tar archive
gzip: stdin: unexpected end of file
/bin/tar: Child returned status 1
/bin/tar: Error is not recoverable: exiting now
Warning message:
In untar(tarfile = "nlopt-2.4.2.tar.gz") :
'/bin/tar -xf 'nlopt-2.4.2.tar.gz'' returned error code 2
configure: Starting to install library to
/tmp/RtmpSeLv7g/R.INSTALL18a67910d582/nloptr/nlopt-2.4.2
./configure: line 3325: cd: nlopt-2.4.2: No such file or directory
System hangs after last line and when I restart after some time, "nloptr" is not installed and hence I am unable to install "car" package.
Please help me. Thanks in advance.
I was encountering the same problem under R (pure R 3.2.3 on Linux Debian). I was first blocked by another issue during the same installation : the installation process failed to lock directory ~/.../R/x86_64.../3.2 and suggested to remove ~/.../R/x86_64.../3.2/00LOCK-nloptr . I did it, restart the car package installation, and then it blocked at the same point: it needs nlopt.h.
So, I installed libnlopt-dev (sudo apt-get install libnlopt-dev) and re-restart the car installation ... and then it worked.
Ok, this is under linux, but perhaps should you try to focus on installing something about NLOPT under windows.
Good luck.

Resources