gpt4 book ai didi

python - 在 Anaconda Jupyter Notebook (MAC OSX) 中加载 rpy2 时出现导入错误

转载 作者:太空宇宙 更新时间:2023-11-04 04:53:05 25 4
gpt4 key购买 nike

我在 Anaconda 中使用 jupyter notebook 在 python 中加载 rpy2。

在 Anaconda Jupyter Notebook (MAC OSX) 中加载 rpy2 时导入错误

    %load_ext rpy2.ipython

这是我得到的错误:

--------------------------------------------------------------------------- ImportError                               Traceback (most recent call

last) in () ----> 1 get_ipython().magic('load_ext rpy2.ipython')

/Users/carrielin/anaconda/lib/python3.6/site-packages/IPython/core/interactiveshell.py in magic(self, arg_s) 2156 magic_name, _, magic_arg_s = arg_s.partition(' ') 2157 magic_name = magic_name.lstrip(prefilter.ESC_MAGIC) -> 2158 return self.run_line_magic(magic_name, magic_arg_s) 2159 2160

-------------------------------------------------------------------------

/Users/carrielin/anaconda/lib/python3.6/site-packages/IPython/core/interactiveshell.py in run_line_magic(self, magic_name, line) 2077
kwargs['local_ns'] = sys._getframe(stack_depth).f_locals 2078
with self.builtin_trap: -> 2079 result = fn(*args,**kwargs) 2080 return result 2081

in load_ext(self, module_str)

/Users/carrielin/anaconda/lib/python3.6/site-packages/IPython/core/magic.py in (f, *a, **k) 186 # but it's overkill for just that one bit of state. 187 def magic_deco(arg): --> 188 call = lambda f, *a, **k: f(*a, **k) 189 190 if callable(arg):

/Users/carrielin/anaconda/lib/python3.6/site-packages/IPython/core/magics/extension.py in load_ext(self, module_str) 35 if not module_str: 36 raise UsageError('Missing module name.') ---> 37 res = self.shell.extension_manager.load_extension(module_str) 38 39 if res == 'already loaded':

/Users/carrielin/anaconda/lib/python3.6/site-packages/IPython/core/extensions.py in load_extension(self, module_str) 81 if module_str not in sys.modules: 82 with prepended_to_syspath(self.ipython_extension_dir): ---> 83 import(module_str) 84 mod = sys.modules[module_str] 85 if self._call_load_ipython_extension(mod):

/Users/carrielin/anaconda/lib/python3.6/site-packages/rpy2/ipython/init.py in () ----> 1 from .rmagic import load_ipython_extension

/Users/carrielin/anaconda/lib/python3.6/site-packages/rpy2/ipython/rmagic.py in () 51 # numpy and rpy2 imports 52 ---> 53 import rpy2.rinterface as ri 54 import rpy2.robjects as ro 55 import rpy2.robjects.packages as rpacks

/Users/carrielin/anaconda/lib/python3.6/site-packages/rpy2/rinterface/init.py in () 48 del(os) 49 ---> 50 from rpy2.rinterface._rinterface import (baseenv, 51 emptyenv, 52 endr,

ImportError: dlopen(/Users/carrielin/anaconda/lib/python3.6/site-packages/rpy2/rinterface/_rinterface.cpython-36m-darwin.so, 2): Library not loaded: @rpath/libiconv.2.dylib Referenced from: /Users/carrielin/anaconda/lib/python3.6/site-packages/rpy2/rinterface/_rinterface.cpython-36m-darwin.so Reason: Incompatible library version: _rinterface.cpython-36m-darwin.so requires version 9.0.0 or later, but libiconv.2.dylib provides version 8.0.0

我还没有搜索过这个问题的其他答案,正在等待您的帮助。

有人可以帮我解决上面的错误吗?

最佳答案

尽管这是针对不同的问题,但这篇文章中的修复对我有用:passenger meet Library not loaded error : liblzma.5.dylib

只需在终端中brew install xz。如果您没有 brew,可以在这里获取:https://brew.sh/

关于python - 在 Anaconda Jupyter Notebook (MAC OSX) 中加载 rpy2 时出现导入错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47737764/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com