Failing to combine python buildpack with R buildpack
Toekan opened this issue · 11 comments
Hi,
I'm trying to use this buildpack and the heroku maintained Python buildpack in one app, when trying to do
heroku run python
after installing both (git push heroku master) ImportError: No module named site from Python. When deleting the R buildpack and rebuilding the slug, I do manage to run Python. I assume this buildpack changes some things in the slug environment? Does anyone how to solve this problem?
Some extra information:
I have no Procfile. Only trying to run a one-off dyno, hence heroku run.
R does work, both when also installing the python buildpack and when not.
I have a init.R (which succesfully installs some packages) and requirements.txt and runtime.txt files for the python build (again, they do get recognised, while building the slug the correct packages get pip installed)
Which python library are you using? Assuming you are calling R from Python.
Not trying to call R from Python, just trying to have a slug where I can run both my R scripts and my Python scripts. Python basically fails from the moment when I try to launch it. That's why I'm so surprised that (and took me a while to realise) that Python works when I get rid of the R buildpack.
Ok, I'll try replicate your issue.
Ok, I've found the issue. It has to do with the PYTHONHOME
environment variable.
Deploy your app with both buildpacks, then run heroku run /bin/bash
and run unset PYTHONHOME
and then your python or R commands, it works.
I'm going to look into what the differences are between deploying with and without the R buildpack, which may explain this.
Mmm, seems it is rather the PATH
environment variable, since with the R buildpack included, which python
resolves to /usr/bin/python
, whereas with only the python buildpack it resolves to /app/.heroku/python/bin/python
.
I've done the unset PYTHONHOME, which indeed makes python and R work, but I can't import the installed python packages now (which I can when only using the python buildpack), I get the standard:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named pandas
Thanks for all (and very quick) help btw! :)
np. Correcting the PATH
variable will fix this.
I.e. After running heroku run /bin/bash
, run export PATH=/app/.heroku/python/bin:/bin:/app/.tools/fakeroot/bin:/app/.tools/fakechroot/sbin:/app/.tools/fakechroot/bin:./bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/bin:/usr/bin
I'm researching a better way to solve this, since compile#L308 isn't playing nicely with other buildpacks.
This gist with the code to replicate the issue.
Running into this issue as well... :(
Also hitting this issue. Any update, much appreciated.
I recommend using heroku-docker-r instead, since it works in a compatible way with your project files, requires a very simple/easy change, and doesn't suffer from the issues of the current (heroku-16) buildpack version.