rpy2 / rpy2

Interface to use R from Python
https://rpy2.github.io
GNU General Public License v2.0
547 stars 72 forks source link

Rpy2 importr gives undefined symbol: libiconv error for readxl and Haven packages #923

Closed RPUTHUMA closed 2 years ago

RPUTHUMA commented 2 years ago

I have created a R model using Readxl and haven package and have pickled the model using saveRDS function. Now when i try to load the model using readRDS the package import for readxl and haven packages fail i am using importr and trying to load the readxl package

To Reproduce

packages=[] packages.append({"name": "readxl", "version": "1.3.1"}) p_list = [package["name"] for package in packages] import rpy2.robjects.packages as rpackages for package in p_list:        rpackages.importr(package, on_conflict="warn")

Expected behavior it should be able to load the package without any issue

Error unable to load shared object '/opt/miniconda/lib/R/library/readxl/libs/readxl.so': /opt/miniconda/lib/R/library/readxl/libs/readxl.so: undefined symbol: libiconv Calls: -> loadNamespace -> library.dynam -> dyn.load

lgautier commented 2 years ago

This is due to your environment, that is how R and packages were installed. From the path you provide conda is likely involved. See https://github.com/rpy2/rpy2/issues/771.