Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can not find the R_HOME and the error :cannot find system Renviron #1067

Open
honghh2018 opened this issue Oct 17, 2023 · 2 comments
Open

can not find the R_HOME and the error :cannot find system Renviron #1067

honghh2018 opened this issue Oct 17, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@honghh2018
Copy link

honghh2018 commented Oct 17, 2023

Describe the issue or bug
the error lying below:
cannot find system Renviron
Fatal error: unable to open the base package

I build the R-4.2.0 with R-shared lib parameter myself in centos 7.9 platform
and then i use python3.8.10 virtual env to import the rpy2 module it trigger error

in my virtual env i typing the python -m rpy2.situation it show me below info:

(app2) [admin@cloud ~]$ python -m rpy2.situation
rpy2 version:
3.4.5
Python version:
3.8.10 (default, Aug  4 2023, 15:06:38) 
[GCC 9.3.0]
Looking for R's HOME:
    Environment variable R_HOME: /public/syssoft/R-4.2.3
    Calling `R RHOME`: /public/syssoft/R-4.2.3/lib64/R
    Environment variable R_LIBS_USER: None
    Warning: The environment variable R_HOME differs from the default R in the PATH.
R's additions to LD_LIBRARY_PATH:
/public/syssoft/R-4.2.3/lib64/R/lib:/public/syssoft/python-3.8.10/lib:/usr/local/gcc-9.3.0/lib64
R_HOME--> /public/syssoft/R-4.2.3
R version:
    In the PATH: R version 4.2.3 (2023-03-15) -- "Shortstop Beagle"
    Loading R library from rpy2: OK
Additional directories to load R packages from:
None
C extension compilation:
/public/home/admin/.virtualenvs/app2/lib/python3.8/site-packages/rpy2/situation.py:200: UserWarning: R emitting a warning: WARNING: ignoring environment value of R_HOME
  warnings.warn('R emitting a warning: %s' % output[0])
  include:
  ['/public/syssoft/R-4.2.3/lib64/R/include']
  libraries:
  ['R', 'pcre', 'lzma', 'bz2', 'z', 'rt', 'dl', 'm']
  library_dirs:
  ['/usr/local/lib64', '/public/syssoft/R-4.2.3/lib64/R/lib']
  extra_compile_args:
  []
  extra_link_args:
  ['-Wl,--export-dynamic', '-fopenmp']

To Reproduce
the python code i write lying below:

import os
import threading


os.environ['R_HOME']="/public/syssoft/R-4.2.3"


from rpy2.rinterface_lib import openrlib
import rpy2.situation
import rpy2.robjects as robjects
from rpy2.robjects import pandas2ri
import pandas as pd

in my app2 virtual env to running this python script "python test.py"
it show me below error:
cannot find system Renviron
Fatal error: unable to open the base package

Expected behavior
how to fix this issue ?

Error
cannot find system Renviron
Fatal error: unable to open the base package

Additional context
Add any other context about the problem here.
Providing the output of running python -m rpy2.situation is highly recommended.

rpy2 version:
3.4.5
Python version:
3.8.10 (default, Aug  4 2023, 15:06:38) 
[GCC 9.3.0]
Looking for R's HOME:
    Environment variable R_HOME: /public/syssoft/R-4.2.3
    Calling `R RHOME`: /public/syssoft/R-4.2.3/lib64/R
    Environment variable R_LIBS_USER: None
    Warning: The environment variable R_HOME differs from the default R in the PATH.
R's additions to LD_LIBRARY_PATH:
/public/syssoft/R-4.2.3/lib64/R/lib:/public/syssoft/python-3.8.10/lib:/usr/local/gcc-9.3.0/lib64
R_HOME--> /public/syssoft/R-4.2.3
R version:
    In the PATH: R version 4.2.3 (2023-03-15) -- "Shortstop Beagle"
    Loading R library from rpy2: OK
Additional directories to load R packages from:
None
C extension compilation:
/public/home/admin/.virtualenvs/app2/lib/python3.8/site-packages/rpy2/situation.py:200: UserWarning: R emitting a warning: WARNING: ignoring environment value of R_HOME
  warnings.warn('R emitting a warning: %s' % output[0])
  include:
  ['/public/syssoft/R-4.2.3/lib64/R/include']
  libraries:
  ['R', 'pcre', 'lzma', 'bz2', 'z', 'rt', 'dl', 'm']
  library_dirs:
  ['/usr/local/lib64', '/public/syssoft/R-4.2.3/lib64/R/lib']
  extra_compile_args:
  []
  extra_link_args:
  ['-Wl,--export-dynamic', '-fopenmp']
@honghh2018 honghh2018 added the bug Something isn't working label Oct 17, 2023
@honghh2018
Copy link
Author

It was very weird.
i ln -s the /usr/local/gcc-9.3.0/lib64/libgfortran.so.5 into directory /lib64/libgfortran.so.5
it show me below error:
cannot find system Renviron
Fatal error: unable to open the base package
if i delete the /lib64/libgfortran.so.5 file
it show me below:
Exception in thread django-main-thread:
Traceback (most recent call last):
File "/public/syssoft/python-3.8.10/lib/python3.8/threading.py", line 932, in _bootstrap_inner
self.run()
File "/public/syssoft/python-3.8.10/lib/python3.8/threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "/public/home/admin/.virtualenvs/app2/lib/python3.8/site-packages/django/utils/autoreload.py", line 64, in wrapper
fn(*args, **kwargs)
File "/public/home/admin/.virtualenvs/app2/lib/python3.8/site-packages/channels/management/commands/runserver.py", line 75, in inner_run
self.check(display_num_errors=True)
File "/public/home/admin/.virtualenvs/app2/lib/python3.8/site-packages/django/core/management/base.py", line 419, in check
all_issues = checks.run_checks(
File "/public/home/admin/.virtualenvs/app2/lib/python3.8/site-packages/django/core/checks/registry.py", line 76, in run_checks
new_errors = check(app_configs=app_configs, databases=databases)
File "/public/home/admin/.virtualenvs/app2/lib/python3.8/site-packages/django/core/checks/urls.py", line 13, in check_url_config
return check_resolver(resolver)
File "/public/home/admin/.virtualenvs/app2/lib/python3.8/site-packages/django/core/checks/urls.py", line 23, in check_resolver
return check_method()
File "/public/home/admin/.virtualenvs/app2/lib/python3.8/site-packages/django/urls/resolvers.py", line 412, in check
for pattern in self.url_patterns:
File "/public/home/admin/.virtualenvs/app2/lib/python3.8/site-packages/django/utils/functional.py", line 48, in get
res = instance.dict[self.name] = self.func(instance)
File "/public/home/admin/.virtualenvs/app2/lib/python3.8/site-packages/django/urls/resolvers.py", line 598, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/public/home/admin/.virtualenvs/app2/lib/python3.8/site-packages/django/utils/functional.py", line 48, in get
res = instance.dict[self.name] = self.func(instance)
File "/public/home/admin/.virtualenvs/app2/lib/python3.8/site-packages/django/urls/resolvers.py", line 591, in urlconf_module
return import_module(self.urlconf_name)
File "/public/syssoft/python-3.8.10/lib/python3.8/importlib/init.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 1014, in _gcd_import
File "", line 991, in _find_and_load
File "", line 975, in _find_and_load_unlocked
File "", line 671, in _load_unlocked
File "", line 848, in exec_module
File "", line 219, in _call_with_frames_removed
File "/tmp/pycharm_project_507/app2/urls.py", line 61, in
path('web/', include(('apps.web.urls', 'apps.web'), namespace="web")), # 反向的时候web:register
File "/public/home/admin/.virtualenvs/app2/lib/python3.8/site-packages/django/urls/conf.py", line 34, in include
urlconf_module = import_module(urlconf_module)
File "/public/syssoft/python-3.8.10/lib/python3.8/importlib/init.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 1014, in _gcd_import
File "", line 991, in _find_and_load
File "", line 975, in _find_and_load_unlocked
File "", line 671, in _load_unlocked
File "", line 848, in exec_module
File "", line 219, in _call_with_frames_removed
File "/tmp/pycharm_project_507/apps/web/urls.py", line 38, in
from apps.web.views.projects.visualiation import visulization as corporate_visulization
File "/tmp/pycharm_project_507/apps/web/views/projects/visualiation/visulization.py", line 13, in
from apps.web.ext.mongo_process.func.subcluster.gene_expr_render_mongo import get_gene_expr_mongodb
File "/tmp/pycharm_project_507/apps/web/ext/mongo_process/func/subcluster/gene_expr_render_mongo/get_gene_expr_mongodb.py", line 2, in
from apps.web.views.projects.visualiation.utils.rpy2_thread import execute_r_script
File "/tmp/pycharm_project_507/apps/web/views/projects/visualiation/utils/rpy2_thread.py", line 9, in
from rpy2.rinterface_lib import openrlib
File "/public/home/admin/.virtualenvs/app2/lib/python3.8/site-packages/rpy2/rinterface_lib/openrlib.py", line 53, in
rlib = _dlopen_rlib(R_HOME)
File "/public/home/admin/.virtualenvs/app2/lib/python3.8/site-packages/rpy2/rinterface_lib/openrlib.py", line 46, in _dlopen_rlib
rlib = ffi.dlopen(lib_path)
OSError: cannot load library '/public/syssoft/R-4.2.3/lib64/R/lib/libR.so': libgfortran.so.5: cannot open shared object file: No such file or directory

@lgautier
Copy link
Member

Your system's linker might not know that library can be found in /public/syssoft/R-4.2.3/lib64/R/lib.
Did you try

export LD_LIBRARY_PATH="$(python -m rpy2.situation LD_LIBRARY_PATH)":${LD_LIBRARY_PATH}

before running Python in the same terminal?

(see https://github.com/rpy2/rpy2#issues-loading-shared-c-libraries)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants