错误:试图猜测R的家,但路径中没有命令“R”

2024-06-16 12:00:52 发布

您现在位置:Python中文网/ 问答频道 /正文

我看到了很多关于这个错误的问题,但是没有一个建议的解决方案适合我。我在Heroku上部署了一个python应用程序,但是推它的时候出现了这个错误。我正在使用 https://github.com/virtualstaticvoid/heroku-buildpack-r.git#heroku-16 和heroku/python作为我的应用程序的两个构建包。我使用的是python3.6.8,正在安装rpy2.9.5

在部署时,heroku首先安装R(成功地,存储库中有一个init.R文件),然后将应用检测为Python应用并开始安装依赖项(在需求.txt文件),并在到达rpy2==2.9.5时给出错误

我看到了this answer,但不知道如何在Heroku上尝试这个。你知道吗

以下是部署尝试的完整日志

-----> R Console app detected
-----> Vendoring R 3.4.4 for heroku-16 stack (latest)
       Retrieving R binaries from cache
-----> Executing R init script
       Installing package into ‘/usr/local/lib/R/site-library’
       (as ‘lib’ is unspecified)
       trying URL 'https://cloud.r-project.org/src/contrib/blockTools_0.6-3.tar.gz'
       Content type 'application/x-gzip' length 51373 bytes (50 KB)
       ==================================================
       downloaded 50 KB

       * installing *source* package ‘blockTools’ ...
       ** package ‘blockTools’ successfully unpacked and MD5 sums checked
       ** libs
       gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG      -fpic  -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c getDist.c -o getDist.o
       gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG      -fpic  -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c naive.c -o naive.o
       gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG      -fpic  -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c optgreed.c -o optgreed.o
       gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG      -fpic  -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c util.c -o util.o
       g++ -shared -L/usr/lib/R/lib -Wl,-Bsymbolic-functions -Wl,-z,relro -o blockTools.so getDist.o naive.o optgreed.o util.o -L/usr/lib/R/lib -lR
       installing to /usr/local/lib/R/site-library/blockTools/libs
       ** R
       ** data
       ** demo
       ** inst
       ** preparing package for lazy loading
       ** help
       *** installing help indices
       ** building package indices
       ** testing if installed package can be loaded
       * DONE (blockTools)

       The downloaded source packages are in
        ‘/tmp/RtmpKojUrP/downloaded_packages’
       Loading required package: blockTools
       Unit 1 data stored as file sdata.RData.
       The current working directory is /
       Unit 1 assigned to Treatment 2.
       The new data as entered:
                  ID [API INPUT] age          Tr
       1 [API INPUT] [API INPUT]  25 Treatment 2
       R 3.4.4 successfully installed (with init)
-----> Caching build outputs
       Build took 50 seconds to complete
-----> Python app detected
-----> Installing python-3.6.8
-----> Installing pip
-----> Installing SQLite3
-----> Installing requirements with pip
       Collecting falcon==1.4.1 (from -r /tmp/build_888a086087211b8118b0e152044beded/requirements.txt (line 1))
         Downloading https://files.pythonhosted.org/packages/e8/d0/20bb807dee65f1f163754670557b128eafce1710f6c9c363a38e357f3783/falcon-1.4.1-py2.py3-none-any.whl (159kB)
       Collecting gunicorn==19.8.1 (from -r /tmp/build_888a086087211b8118b0e152044beded/requirements.txt (line 2))
         Downloading https://files.pythonhosted.org/packages/55/cb/09fe80bddf30be86abfc06ccb1154f97d6c64bb87111de066a5fc9ccb937/gunicorn-19.8.1-py2.py3-none-any.whl (112kB)
       Collecting Jinja2==2.10 (from -r /tmp/build_888a086087211b8118b0e152044beded/requirements.txt (line 3))
         Downloading https://files.pythonhosted.org/packages/7f/ff/ae64bacdfc95f27a016a7bed8e8686763ba4d277a78ca76f32659220a731/Jinja2-2.10-py2.py3-none-any.whl (126kB)
       Collecting MarkupSafe==1.0 (from -r /tmp/build_888a086087211b8118b0e152044beded/requirements.txt (line 4))
         Downloading https://files.pythonhosted.org/packages/4d/de/32d741db316d8fdb7680822dd37001ef7a448255de9699ab4bfcbdf4172b/MarkupSafe-1.0.tar.gz
       Collecting python-mimeparse==1.6.0 (from -r /tmp/build_888a086087211b8118b0e152044beded/requirements.txt (line 5))
         Downloading https://files.pythonhosted.org/packages/26/2e/03bce213a9bf02a2750dcb04e761785e9c763fc11071edc4b447eacbb842/python_mimeparse-1.6.0-py2.py3-none-any.whl
       Collecting rpy2==2.9.5 (from -r /tmp/build_888a086087211b8118b0e152044beded/requirements.txt (line 6))
         Downloading https://files.pythonhosted.org/packages/02/d1/074ffbbe7b4bf74c60b75d74c8e67a1e4515b0d85f85cd6540e39610754a/rpy2-2.9.5.tar.gz (194kB)
           Complete output from command python setup.py egg_info:
           Error: Tried to guess R's HOME but no command 'R' in the PATH.

           ----------------------------------------
       Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-d2_abgxe/rpy2/
 !     Push rejected, failed to compile Python app.
 !     Push failed

Tags: fromhttpsorgbuildtxtpackagelibpackages