How to install python module on Heroku cedar stack with Rails

妖精的绣舞 提交于 2020-01-07 03:54:33

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!