简体   繁体   English

在Mac上安装rpy或rpy2

[英]Installing rpy or rpy2 on mac

I'm in the process of trying to install rpy or rpy2 on my Macbook so I can use R from python. 我正在尝试在Macbook上安装rpy或rpy2,以便可以从python使用R。 Information about rpy can be found here: http://rpy.sourceforge.net/index.html 有关rpy的信息可以在这里找到: http ://rpy.sourceforge.net/index.html

My problem is in the installation itself. 我的问题是安装本身。 I can't seem to make python recognize Rpy using import command: I keep getting the message "No module named rpy2". 我似乎无法使用import命令使python识别Rpy:我不断收到消息“没有名为rpy2的模块”。 Does anyone know where I can find some step-by-step instructions on how to successfully install this? 有谁知道我在哪里可以找到有关如何成功安装此软件的逐步说明? I have already installed both python and R, and both are working perfectly. 我已经安装了python和R,并且都工作正常。 Thanks in advance! 提前致谢!

Try easy_install rpy2 . 尝试easy_install rpy2 You need to install easy_install before that. 在此之前,您需要安装easy_install

I took that from here 我从这里拿来的

I long gave up on these issues on my Mac. 我长期在Mac上放弃了这些问题。 Since I installed OS Lion, I found that I needed to switch to MacPorts and then installing packages like RPy2 from their repository . 自从安装OS Lion以来,我发现我需要切换到MacPorts ,然后从其存储库中安装RPy2之类的软件包。

I know some people like to dig into the system and learn all the idiosyncrasies of the architecture and keep a vanilla install of python on their Mac. 我知道有些人喜欢深入研究系统,学习该体系结构的所有特质,并在Mac上保留python的原始安装。 I find that i get problems like yours too frequently and they distract me from real work. 我发现我经常遇到像您这样的问题,它们使我无法进行实际工作。

I just download the MacPorts modules when I need them and get on with the problem at hand. 我只在需要时下载MacPorts模块 ,然后处理当前的问题。 Others say the same thing about HomeBrew but I have only worked with MacPorts and it makes installation of modules too easy. 其他人对HomeBrew也有同样的看法,但是我只使用MacPorts,它使模块的安装太容易了。 You may want to invest some time investigating if either of these solutions work for you. 如果这些解决方案中的任何一种都适合您,您可能需要花费一些时间进行调查。

Another approach to using package managers like MacPorts or HomeBrew is to use a virtualenv and install python and all related modules there. 使用MacPorts或HomeBrew等软件包管理器的另一种方法是使用virtualenv并在其中安装python和所有相关模块。 Again, not a solution I have tried directly, but a quick search will show you many endorsements for this approach to using a specific Python executable and packaging its modules In an isolated environment. 同样,这不是我直接尝试过的解决方案,但是快速搜索将向您展示许多支持这种方法的方法,该方法使用特定的Python可执行文件并将其模块包装在隔离的环境中。

只要在Mac上安装了pip,生活就很容易了:sudo pip install rpy2

If you want rpy it isn't on macport, at least a search of their packages only showed rpy2. 如果您希望rpy不在macport上,则至少对其软件包的搜索仅显示rpy2。 According to the rpy web site its in fink. 根据rpy网站的说法,它确实存在。 However at the moment fink is down so I can't verify this. 但是此刻芬克病倒了,所以我无法验证这一点。 Which is irritating because I need rpy (not rpy2) because another package has a dependency on it. 这很烦人,因为我需要rpy(而不是rpy2),因为另一个软件包对此具有依赖性。

I also tried pip to find rpy and it said no package, which is a shame because pip is great for python installs (provided I remember to use 'sudo' first. 我还尝试了pip来找到rpy,但它说没有软件包,这很可惜,因为pip非常适合python安装(前提是我记得首先要使用'sudo'。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM