问题
We have a rails app running on the Heroku Cedar stack, and we have a need for an external python module, namely 'pyPdf'. Unfortunately it is not one of the pre-installed python modules.
Is there a way to install python modules on the Cedar stack? I've tried to add a requirements.txt at the root of my app, but this doesn't seem to work. Probably because Heroku dismisses it after seeing our Gemfile.
Any help appreciated.
回答1:
Is this module something that you're trying to access from your Rails application? If so, you can always access bash on a dyno to download and compile a library (if compilation is needed) and then stuff the resultant file into your application codebase (somewhere like /app/bin). Then you can refer to this binary in your code.
To access bash on a dyno:
heroku run bash --app your_app_name
An example of the above:
http://theprogrammingbutler.com/blog/archives/2011/07/28/running-pdftotext-on-heroku/
Note, you won't be able to install anything into a dyno because the dynos change on an ad-hoc basis and you'll never know what state your in. Also note that the moment you exit from bash that dyno is killed, so don't leave anything laying around - it'll get vaporised.
来源:https://stackoverflow.com/questions/8591433/how-to-install-python-module-on-heroku-cedar-stack-with-rails