python rpy2 报错

Python 3.8.12 (default, Apr 17 2022, 10:38:39)
[GCC 6.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import rpy2.robjects as robj
Error: package or namespace load failed for ‘methods’ in dyn.load(file, DLLpath = DLLpath, ...):
 unable to load shared object '/share/work/biosoft/R/R-v4.0.3/lib64/R/library/methods/libs/methods.so':
  /share/work/biosoft/R/R-v4.0.3/lib64/R/library/methods/libs/methods.so: undefined symbol: R_dot_Generic
Error: package or namespace load failed for ‘utils’ in dyn.load(file, DLLpath = DLLpath, ...):
 unable to load shared object '/share/work/biosoft/R/R-v4.0.3/lib64/R/library/utils/libs/utils.so':
  /share/work/biosoft/R/R-v4.0.3/lib64/R/library/utils/libs/utils.so: undefined symbol: ALTREP_LENGTH
Error: package or namespace load failed for ‘grDevices’ in dyn.load(file, DLLpath = DLLpath, ...):
 unable to load shared object '/share/work/biosoft/R/R-v4.0.3/lib64/R/library/grDevices/libs/grDevices.so':
  /share/work/biosoft/R/R-v4.0.3/lib64/R/library/grDevices/libs/grDevices.so: undefined symbol: ALTREP_LENGTH
Error: package or namespace load failed for ‘graphics’ in dyn.load(file, DLLpath = DLLpath, ...):
 unable to load shared object '/share/work/biosoft/R/R-v4.0.3/lib64/R/library/grDevices/libs/grDevices.so':
  /share/work/biosoft/R/R-v4.0.3/lib64/R/library/grDevices/libs/grDevices.so: undefined symbol: ALTREP_LENGTH
Error: package or namespace load failed for ‘stats’ in dyn.load(file, DLLpath = DLLpath, ...):
 unable to load shared object '/share/work/biosoft/R/R-v4.0.3/lib64/R/library/grDevices/libs/grDevices.so':
  /share/work/biosoft/R/R-v4.0.3/lib64/R/library/grDevices/libs/grDevices.so: undefined symbol: ALTREP_LENGTH
Error: package or namespace load failed for ‘methods’ in dyn.load(file, DLLpath = DLLpath, ...):
 unable to load shared object '/share/work/biosoft/R/R-v4.0.3/lib64/R/library/methods/libs/methods.so':
  /share/work/biosoft/R/R-v4.0.3/lib64/R/library/methods/libs/methods.so: undefined symbol: R_dot_Generic
During startup - Warning messages:
1: package "methods" in options("defaultPackages") was not found
2: package ‘utils’ in options("defaultPackages") was not found
3: package ‘grDevices’ in options("defaultPackages") was not found
4: package ‘graphics’ in options("defaultPackages") was not found
5: package ‘stats’ in options("defaultPackages") was not found
6: package ‘methods’ in options("defaultPackages") was not found
R[write to console]: Error in dyn.load(file, DLLpath = DLLpath, ...) :
  unable to load shared object '/share/work/biosoft/R/R-v4.0.3/lib64/R/library/methods/libs/methods.so':
  /share/work/biosoft/R/R-v4.0.3/lib64/R/library/methods/libs/methods.so: undefined symbol: R_dot_Generic

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/share/work/biosoft/python/Python3/lib/python3.8/site-packages/rpy2/robjects/__init__.py", line 18, in <module>
    from rpy2.robjects.robject import RObjectMixin, RObject
  File "/share/work/biosoft/python/Python3/lib/python3.8/site-packages/rpy2/robjects/robject.py", line 86, in <module>
    class RObjectMixin(abc.ABC):
  File "/share/work/biosoft/python/Python3/lib/python3.8/site-packages/rpy2/robjects/robject.py", line 98, in RObjectMixin
    __show = _get_exported_value('methods', 'show')
  File "/share/work/biosoft/python/Python3/lib/python3.8/site-packages/rpy2/rinterface_lib/conversion.py", line 45, in _
    cdata = function(*args, **kwargs)
  File "/share/work/biosoft/python/Python3/lib/python3.8/site-packages/rpy2/rinterface.py", line 810, in __call__
    raise embedded.RRuntimeError(_rinterface._geterrmessage())
rpy2.rinterface_lib.embedded.RRuntimeError: Error in dyn.load(file, DLLpath = DLLpath, ...) :
  unable to load shared object '/share/work/biosoft/R/R-v4.0.3/lib64/R/library/methods/libs/methods.so':
  /share/work/biosoft/R/R-v4.0.3/lib64/R/library/methods/libs/methods.so: undefined symbol: R_dot_Generic




请先 登录 后评论

1 个回答

omicsgene - 生物信息
擅长:重测序,遗传进化,转录组,GWAS

添加环境变量:


export R_HOME=/share/work/biosoft/R/R-v4.0.3/lib64/R

export LD_LIBRARY_PATH=${R_HOME}/lib:${LD_LIBRARY_PATH}


又报错:


Python 3.8.12 (default, Apr 17 2022, 10:38:39)
[GCC 6.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import rpy2.robjects as robj
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/share/work/biosoft/python/Python3/lib/python3.8/site-packages/rpy2/robjects/__init__.py", line 26, in <module>
    from . import vectors
  File "/share/work/biosoft/python/Python3/lib/python3.8/site-packages/rpy2/robjects/vectors.py", line 14, in <module>
    import jinja2  # type: ignore
  File "/share/work/biosoft/python/Python3/lib/python3.8/site-packages/jinja2/__init__.py", line 12, in <module>
    from .environment import Environment
  File "/share/work/biosoft/python/Python3/lib/python3.8/site-packages/jinja2/environment.py", line 25, in <module>
    from .defaults import BLOCK_END_STRING
  File "/share/work/biosoft/python/Python3/lib/python3.8/site-packages/jinja2/defaults.py", line 3, in <module>
    from .filters import FILTERS as DEFAULT_FILTERS  # noqa: F401
  File "/share/work/biosoft/python/Python3/lib/python3.8/site-packages/jinja2/filters.py", line 13, in <module>
    from markupsafe import soft_unicode
ImportError: cannot import name 'soft_unicode' from 'markupsafe' (/share/work/biosoft/python/Python3/lib/python3.8/site-packages/markupsafe/__init__.py)
>>> exit()

解决办法,应该是版本问题:
python3 -m pip install markupsafe==2.0.1







请先 登录 后评论
  • 1 关注
  • 0 收藏,2245 浏览
  • 提出于 2022-04-18 11:14

相似问题