Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

R fails to load igraph in conda environment

I am trying to run an RShiny app in a WSL2 installation of Ubuntu on Windows. I am no expert in R, but I feel this is a problem due to conda interaction with R. I run the following commands:

conda create -n r_env r-essentials r-base
conda activate r_env
conda install -c conda-forge r-shiny
conda install -c r r-visnetwork
conda install -c conda-forge r-dplyr
conda install -c r r-dt
conda install -c conda-forge r-igraph
conda install -c r r-leaflet
conda install -c conda-forge r-rgdal
conda install -c r r-shinydashboard
conda install -c conda-forge r-shinywidgets
conda install -c conda-forge r-shinycssloaders
conda install -c conda-forge r-igraph

When I run R and type in : library(igraph) i get:

->Error: package or namespace load failed for ‘igraph’ in dyn.load(file, DLLpath = DLLpath, ...):
 unable to load shared object '/home/carlo/anaconda3/envs/r_env/lib/R/library/igraph/libs/igraph.so':

but I can list it, it's there:

ll /home/carlo/anaconda3/envs/r_env/lib/R/library/igraph/libs/igraph.so
-> -rwxrwxr-x 1 carlo carlo 3816608 Mar 31 15:38 /home/carlo/anaconda3/envs/r_env/lib/R/library/igraph/libs/igraph.so

Did anybody encounter a similar problem?

The igraph library was meant to load correctly

like image 860
user15233037 Avatar asked Sep 29 '26 12:09

user15233037


1 Answers

(My Opinion) I would caution against the use of the r channel and the r-essentials package. The Continuum/Anaconda support for R was a good college-try, but is since outmoded and superseded by the broader CRAN support that Conda Forge provides. Users managing R environments will find a better experience ignoring any Continuum/Anaconda documentation and exclusively using Conda Forge for their R environments. (End Opinion)


Mixing channels can lead to symbol reference errors. Furthermore, sequences of ad hoc installations are subpar - instead specify through a YAML.

The following YAML file works just fine on linux-64, osx-64, and win-64 platforms:

so-igraph so-igraph.yaml

name: so-igraph
channels:
  - conda-forge
dependencies:
  - r-base=4.1  # adjust to desired version
  - r-shiny
  - r-visnetwork
  - r-dplyr
  - r-dt
  - r-igraph
  - r-leaflet
  - r-rgdal
  - r-shinydashboard
  - r-shinywidgets
  - r-shinycssloaders
  - r-igraph

Which can be used with

conda env create -n so-igraph -f so-igraph.yaml
conda activate so-igraph
like image 199
merv Avatar answered Oct 01 '26 04:10

merv



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!