premium ons mongolab dev addons addon heroku

ons - Heroku RPy RHOME descubrimiento



heroku postgresql premium 2 (1)

Después de algunas sugerencias útiles de @ bwarren2, creo que tengo una forma más limpia de usar R, python y rpy2 juntos en Heroku.

En este ejemplo, estoy usando el buildpack de python heroku-buildpack-python-sklearn, que contiene numpy, scipy y scikit-learn de compilaciones binarias. La biblioteca Rpy2 tiene una buena integración numpy por lo que es probable que desee comenzar con esto. Si no, entonces el mismo enfoque funciona con python buildpack normal.

Haga un archivo .buildpacks como este:

https://github.com/virtualstaticvoid/heroku-buildpack-r.git https://github.com/dbrgn/heroku-buildpack-python-sklearn/

Un archivo init.r opcional que instala bibliotecas R y este archivo requirements.txt:

numpy==1.7.0 scipy==0.11.0 scikit-learn==0.13.1 matplotlib==1.1.0 rpy2==2.3.8

Como estamos compilando versiones binarias de estos (debido a BLAS y otras dependencias), los números de versión deben coincidir exactamente.

Luego hacemos el proceso normal para usar los paquetes de construcción múltiple. Sin embargo, el buildpack de python necesita saber dónde se instalaron R y algunas bibliotecas. El sistema de construcción de babosas en Heroku no pasa todas las variables de entorno establecidas en el buildpack R al buildpack de python.

Sin embargo, podemos usar la nueva característica user-env-compile de Heroku labs y establecer variables para PATH y LD_LIBRARY_PATH explícitamente. Esto es lo que hice ...

# make a test repo git init # add our files git add init.r git add requirements.txt git add .buildpacks # commit the files git ci -m"testing using user-env-compile" # create a new app using the multi buildpack code heroku create --buildpack https://github.com/ddollar/heroku-buildpack-multi.git # turn on user-env-compile, that allows config vars when compiling slug # see https://devcenter.heroku.com/articles/labs-user-env-compile heroku labs:enable user-env-compile # set the path variables explicitly, so python knows where R is located heroku config:set PATH=/app/vendor/R/bin:/app/vendor/gcc-4.3/bin:/app/.heroku/python/bin:/usr/local/bin:/usr/bin:/bin heroku config:set LD_LIBRARY_PATH=/usr/lib:/usr/local/lib:/app/vendor/R/lib64/R/modules:/app/vendor/R/lib64/R/lib:/app/vendor/gcc-4.3/lib64 # create the slug git push heroku master # we can now access R from python using rpy2 $ heroku run python Running `python` attached to terminal... up, run.1144 Python 2.7.4 (default, Apr 6 2013, 22:14:13) [GCC 4.4.3] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import rpy2.robjects as robjects >>> pi = robjects.r[''pi''] >>> pi[0] 3.141592653589793

Ediciones: actualicé LD_LIBRARY_PATH para contener / usr / lib y / usr / local / lib, para evitar el problema descrito aquí .

También se agregó matplotlib == 1.1.0 a requirements.txt, que es una versión anterior como se describe aquí .

Estoy intentando ejecutar una aplicación de varios pares de Heroku que usa Python y R. Tengo el buildpack múltiple que instala R primero, pero la instalación de RPy no puede encontrar R a pesar de mis modificaciones a $ PATH. ¿Que esta pasando aqui? R ve a RHOME como "/ app / vendor / R / lib64 / R" cuando se ejecuta init.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 [email protected]: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