【发布时间】:2013-05-08 08:07:09
【问题描述】:
我正在尝试运行一个使用 Python 和 R 的 multipack Heroku 应用程序。我首先安装了 R,但是尽管我对 $PATH 进行了修改,但 RPy 的安装无法找到 R。这里发生了什么?当 init.r 运行时,R 将 RHOME 视为“/app/vendor/R/lib64/R”。
-----> Fetching custom git buildpack... done
-----> Multipack app detected
=====> Downloading Buildpack: https://github.com/virtualstaticvoid/heroku-buildpack-r
=====> Detected Framework: R
Vendoring R 2.15.1
Downloading and unpacking R binaries
Executing init.r script
[1] "/app/vendor/R/lib64/R" #This is me dumping out RHOME from init.r
R 2.15.1 successfully installed
=====> Downloading Buildpack: https://github.com/heroku/heroku-buildpack-python
=====> Detected Framework: Python
-----> No runtime.txt provided; assuming python-2.7.4.
-----> Using Python runtime (python-2.7.4)
-----> Installing dependencies using Pip (1.3.1)
Downloading/unpacking rpy2==2.3.5 (from -r requirements/base.txt (line 22))
Running setup.py egg_info for package rpy2
sh: R: not found
Error: Tried to guess R's HOME but no R command in the PATH.
Complete output from command python setup.py egg_info:
running egg_info
creating pip-egg-info/rpy2.egg-info
writing pip-egg-info/rpy2.egg-info/PKG-INFO
writing top-level names to pip-egg-info/rpy2.egg-info/top_level.txt
writing dependency_links to pip-egg-info/rpy2.egg-info/dependency_links.txt
writing manifest file 'pip-egg-info/rpy2.egg-info/SOURCES.txt'
warning: manifest_maker: standard file '-c' not found
sh: R: not found
Error: Tried to guess R's HOME but no R command in the PATH.
----------------------------------------
Command python setup.py egg_info failed with error code 1 in /tmp/pip-build-u32629/rpy2
Storing complete log in /app/.pip/pip.log
! Heroku push rejected, failed to compile Multipack app
To git@heroku.com:D.git
! [remote rejected] master -> master (pre-receive hook declined)
(venvddd)ben@Watt:~/Projects/D/D$ heroku config:get PATH /home/ben/Projects/D/venvddd/bin:/usr/local/heroku/bin:/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/app/vendor/R/lib64/R:/app/vendor/R/lib64/R/bin
【问题讨论】:
-
rpy2 的
setup.py正在使用os.popen("R RHOME")。在 Heroku 上创建子子进程时,可能正在发生“某些事情”。由于该函数在 Python 中已弃用,因此值得尝试subprocess模块是否解决了该问题。 -
原来问题是 buildpack 安装在 heroku 上是事务性的,因此 $PATH 在安装之间发生变化。分叉 heroku python buildpack 并调整 $PATH 变量使安装运行,但我稍后会遇到更新和更有趣的导入错误。随着它的发展,更多。
-
搞定了!这比您最初预期的要复杂得多,需要修改几个自定义构建包和配置环境变量来管理导入。不过,秘诀在于 Heroku 构建包是事务性的。
-
如果您发现 rpy2 安装过程可以改进的地方,请不要犹豫提出建议(或提供补丁)。
标签: heroku