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.
Related
I did put R on path using the .bashrc file. And yet, I do not have access to R through the command line. I have nevertheless no issues with RStudio. When I check for the R location with which R, I get /home/myself/anaconda3/bin/R. I have Ubuntu 20.04. The error message that I get is /home/myself/anaconda3/lib/R/bin/exec/R: error while loading shared libraries: libreadline.so.6: cannot open shared object file: No such file or directory. I have version R version 4.1.3 which I have installed recently. Working in JupyterLab in anaconda, I installed again R in a conda environement. Unfortunately, I get inside the conda environment the same error message.
When I try to install the missing package, I get the message:libreadline6 : PreDepends: multiarch-support but it is not installable.
I also tried to install libreadline with conda, conda install -c conda-forge m2-libreadline (as suggested on the anaconda site) as well as conda install -n base -c conda-forge libreadline.so.6. The message I get is: `PackagesNotFoundError: The following packages are not available from current channels:
libreadline.so.6
m2-libreadline`
I will highly appreciate your help. Thanks.
I installed broom.mixed package via conda conda install -c conda-forge r-broom.mixed, however, it doesn't import and shows error message:
library(broom.mixed)
Error: package or namespace load failed for ‘broom.mixed’:
.onLoad failed in loadNamespace() for 'TMB', details:
call: dyn.load(file, DLLpath = DLLpath, ...)
error: unable to load shared object '/local/home/hsinhung/anaconda3/envs/r-env/lib/R/library/TMB/libs/TMB.so':
libopenblas.so.0: cannot open shared object file: No such file or directory
2022/1/17 added "hopefully" reproducible examples:
I created a clean R environment in Anaconda via below commands:
conda create -n r_env_test r-essentials r-base (following Anaconda R env instruction)
conda activate r_env_test
conda install -c conda-forge r-broom.mixed (following Anaconda broom.mixed instruction)
then I enter R console, and execute library(broom.mixed). The error pops up right away:
> library(broom.mixed)
Error: package or namespace load failed for ‘broom.mixed’:
.onLoad failed in loadNamespace() for 'TMB', details:
call: dyn.load(file, DLLpath = DLLpath, ...)
error: unable to load shared object '/local/home/hsinhung/anaconda3/envs/r_env_test/lib/R/library/TMB/libs/TMB.so':
libopenblas.so.0: cannot open shared object file: No such file or directory
In addition: Warning message:
package ‘broom.mixed’ was built under R version 3.6.3
As #merv suggested, here the output of package versions in the new test environment:
x86_64-conda_cos6-linux-gnu % conda list '(libblas|liblapack|r-base|r-tmb|r-broom.mixed)'
# packages in environment at /home/hsinhung/anaconda3/envs/r_env_test:
#
# Name Version Build Channel
r-base 3.6.1 haffb61f_2
r-base64enc 0.1_3 r36h96ca727_4
r-broom.mixed 0.2.6 r36h6115d3f_0 conda-forge
r-tmb 1.7.16 r36h0357c0b_0 conda-forge
(r_env_test)
(22-01-17 8:16:12) <0> [~]
x86_64-conda_cos6-linux-gnu %
Any suggestion how I can get this package going in Anaconda?
Improper Channel Mixing
I believe the issue being encountered is primarily driven by mixing the defaults channel (specifically the r channel) and the conda-forge channel. This is known to lead to missing libraries and missing symbol references in shared libraries because Anaconda and Conda Forge use different build stacks and sometimes different recipes.
In this case, r-broom.mixed depends on r-tmb, which on Conda Forge depends on libblas and liblapack, but on the r channel does not have these dependencies.
Recommendation: Conda Forge only
Generally, I recommend that Conda users who want R environments should only use Conda Forge and avoid using the r channel. This is because the r channel has mostly been abandoned from what I can tell (e.g., no R version 4 releases, and most packages have not been updated for over a year).
Furthermore, I would discourage the use of the r-essentials package. Analogous to the Anaconda distribution of Python (anaconda package), the r-essentials package bundles together many packages that are anticipated to be used by data scientists, but some of it simply seems bloated to me. Something specific that troubles me about it is that it ends up pulling in Python in addition to R. No one should need to have Python mixed in with an R environment. This is due to including notebook, which if users really want to load an R environment as a kernel, they only need r-irkernel (as demonstrated below).
In summary, one should be fine simply doing:
conda create -n foo -c conda-forge r-base r-broom.mixed
Demonstration
To verify that the BLAS implementation doesn't make a difference, I tested using MKL and OpenBLAS.
I encounter no issues with the following setup:
## dedicated jupyter environment
mamba create -n jupyter jupyter nb_conda_kernels
## broom.mixed with MKL backend
mamba create -n broom_mkl r-base=4.1 r-broom.mixed r-irkernel 'blas=*=*mkl*'
## broom.mixed with OpenBLAS backend
mamba create -n broom_openblas r-base=4.1 r-broom.mixed r-irkernel 'blas=*=*openblas*'
## launch jupyter
conda activate jupyter
jupyter notebook
With Jupyter launched I can create a new notebook with either the broom_mkl or broom_openblas kernels, and running library(broom.mixed) loads without any error.
This is on osx-64 platform.
This question is motivated by `jupyter notebook` gives error: `"Could not open static file ''"` on macOS
After conda update jupyter, jupyter --version gives jupyter-notebook : 6.0.0
However on https://github.com/jupyter/notebook, clicking Branch: master -> tags I see a 6.0.1 tag.
How can I upgrade to 6.0.1?
> conda install jupyter=6.0.1
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:
- jupyter=6.0.1
Current channels:
- https://repo.anaconda.com/pkgs/main/osx-64
- https://repo.anaconda.com/pkgs/main/noarch
- https://repo.anaconda.com/pkgs/r/osx-64
- https://repo.anaconda.com/pkgs/r/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 can't see any candidates on https://anaconda.org
Is this a dead-end?
First, note that the actual package you want to upgrade/install is notebook, not jupyter. The Anaconda channel hasn't released that version of notebook yet. Conda Forge has it, so you can get it with
conda install -c conda-forge notebook
However, just be aware that compatibility between Conda Forge and Anaconda package builds is not guaranteed. Best practice is to create a new env that prioritizes Conda Forge from the start:
conda create -n my_jupyter_env -c conda-forge jupyter
Generally it isn't a good idea to mess with base env, and if you want something other than a default Anaconda install, I recommend starting with Miniconda and leaving base alone (other than the occasional conda upgrade conda).
I'm getting a little bit crazy with this issue. I'm trying to install an R package using conda in my environment (python 2.7) in my home on a cluster (i.e. without root permissions). I firstly installed R in my env using:
conda install -c r r=3.4
Then:
conda install -c conda-forge python-igraph
(because igraph is required by my library of interest)
and finally:
conda install -c conda-forge r-diffusionmap
Unfortunately when I launch R the following message appears:
Error: package or namespace load failed for 'RevoUtilsMath': .onLoad
failed in loadNamespace() for 'RevoUtilsMath', details: call: NULL
error: Remove Microsoft R and then re-install. Be sure to select MKL
libraries as an install option.
During startup - Warning message:
package 'RevoUtils' was built under R version 3.4.3
What does it mean? How can I solve this?
Thank you in advance
I had this same issue after I installed some libraries (Rcpp included) in my root R, but not my conda environment (which screwed up conda). This would cause kernel death anytime a jupyter notebook running R was even opened.
The fix for me was:
Uninstall Anaconda3
Reinstall Anaconda3
Reinstall all the libraries I needed (mostly just Bioconductor in R)
A few other issues popped up, like package inconsistencies, but I dealt with those as described here.
All R packages on conda-forge (or Bioconda) are compiled against one single version or R for each new release branch (usually starting from patch 1, so 3.x.1, except for 3.4.3). This is due to ABI incompatibility problems.
Also note that defaults and conda-forge channels are (where) not binary compatible (although now they should be). And that since 2018 the default anaconda channel is distributing Microsoft R Open as default R, whether all packages from conda-forge should be preferably used with R from conda-forge.
You should be able to solve this issue by installing R using conda install -c conda-forge r-base.
the same error information for me when I open R for run code in ubuntu platform(18.4), and there is no other useful methods to solve it.My R version is 3.4.3.enter image description here
I am having a tough time installing R-packages that are not available in the Anaconda repositories. My attempts so far can be found here How to install R-packages not in the conda repositories?.
Currently, I am trying to build the R-package rafalib for conda by following the instructions from this article under the heading Building a conda R package.
The first part works fine.
conda skeleton cran rafalib
Out:
Tip: install CacheControl to cache the CRAN metadata
Fetching metadata from http://cran.r-project.org/
Writing recipe for rafalib
Done
The build command runs into errors
conda build r-rafalib
Out:
Removing old build environment
Removing old work directory
BUILD START: r-rafalib-1.0.0-r3.2.2_0
Using Anaconda Cloud api site https://api.anaconda.org
Fetching package metadata: ......
Solving package specifications: .
Error: Packages missing in current linux-64 channels:
- r 3.2.2*
- r-rcolorbrewer
I have r 3.2.2-64bit installed via conda and it runs without problems. I also already have r-colorbrewer installed via conda and I can use that package without issues in R. Why am I getting these errors when trying to build a conda package?
I am on Linux (Antergos, an Arch derivative) with kernel 4.4.5-1-ARCH.
UPDATE 2015/04/19
Thanks to this answer, I found out that I could include the dependencies by building them separately in the same directory as the package I want to install. That didn't work for me, but I also read that I can include a channel in the build command with -c, just as when installing. So now I do:
conda build -c r r-rafalib
This gets passed all the dependency problems, but after fetching, extracting and linking packages, it fails. Here is the end of the error message.
Removing old work directory
Source cache directory is: /home/joel/anaconda2/conda-bld/src_cache
Downloading source to cache: rafalib_1.0.0.tar.gz
Downloading http://cran.r-project.org/src/contrib/rafalib_1.0.0.tar.gz
rafalib_1.0.0. 100% |#######################| Time: 0:00:00 4.87 MB/s
Success
Extracting download
Package: r-rafalib-1.0.0-r3.2.2_0
source tree in: /home/joel/anaconda2/conda-bld/work/rafalib
+ mv DESCRIPTION DESCRIPTION.old
+ grep -v '^Priority: ' DESCRIPTION.old
+ /home/joel/anaconda2/envs/_build/bin/R CMD INSTALL --build .
sh: symbol lookup error: sh: undefined symbol: rl_signal_event_hook
Command failed: /bin/bash -x -e /home/joel/drafts/r-rafalib/build.sh
The error sh: symbol lookup error: sh: undefined symbol: rl_signal_event_hook is the same as I encounter when using install.packages() as reported here.
There is some related discussion in this thread. I have tried to get around this error by installing different versions of ncurses, including this patched version, and I have tried to link the readline libraries, as suggested here, but I keep running into the same error. I'm quite lost at this point and any help to solve this would be greatly appreciated.
Although I started out with a different problem, the final solution turned out to be the same as I posted elsewhere How to install R-packages not in the conda repositories?. I am adding it here for completeness.
In the end, I got around the rl_event_hookproblems by following the approach recommended here and symlinking anaconda's libreadline to the system one:
mv ~/anaconda3/lib/libreadline.s.6.2 ~/anaconda3/lib/libreadline.s.6.2.bak
ln -s /usr/lib/libreadline.so.6.3 ~/anaconda3/lib/libreadline.s.6.2
I am still having troubles installing some dependency heavy R-packages due to failure to load shared objects when using install.packages() from withing R. However, simpler packages work fine and I can get most of the dependency heavy packages from anacondas R-repositories.