如何在Rails的Heroku雪松堆栈上安装python模块 [英] How to install python module on Heroku cedar stack with Rails

查看:177
本文介绍了如何在Rails的Heroku雪松堆栈上安装python模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们在Heroku Cedar栈上运行了一个rails应用程序,我们需要一个外部python模块,即'pyPdf'。不幸的是,它不是预先安装的Python模块之一。



有没有在Cedar栈上安装python模块的方法?我试图在我的应用程序的根目录添加一个requirements.txt,但这似乎不起作用。可能是因为Heroku在看到我们的Gemfile后就驳回了它。



任何帮助表示感谢。 解决方案

这个模块是否正在尝试从Rails应用程序访问?如果是这样,你总是可以通过dyno访问bash来下载和编译一个库(如果需要编译),然后将生成的文件填入应用程序代码库(某处像/ app / bin)。然后你可以在你的代码中引用这个二进制文件。



访问dyno上的bash:

  heroku run bash --app your_app_name 

以上示例:



http://theprogrammingbutler.com/blog/archives/2011/07/28/running-pdftotext-on-heroku/



请注意,您将无法将任何东西安装到测功机中,因为测功机在临时基础上发生变化,并且永远不会知道自己进入的是什么状态。还要注意,当您从bash中退出测功机时,留下任何东西 - 它会蒸发。


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.

解决方案

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.

这篇关于如何在Rails的Heroku雪松堆栈上安装python模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆