如何在Heroku上使用声音文件 [英] How to use soundfile on heroku

查看:67
本文介绍了如何在Heroku上使用声音文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个在Heroku上运行的python flask应用程序,该应用程序使用 soundfile.将soundfile添加到requirements.txt之后,Heroku给了我这个错误:

I have a python flask app I'm running on Heroku which uses the soundfile library. After adding soundfile to requirements.txt Heroku gave me this error:

raise OSError('sndfile library not found')

查找了它,并读到我需要导入libsndfile1库.但是当我也将其添加到requirements.txt时,构建失败并显示以下错误:

I looked it up and read that I needed the libsndfile1 library imported. But when I added that to the requirements.txt as well, the build failed with the error:

找不到libsndfile1的匹配发行版

No matching distribution found for libsndfile1

是否存在导入此程序包的解决方法,以便可以在Heroku上使用soundfile?

Is there a workaround for importing this package so I can use soundfile on Heroku?

推荐答案

libsndfile1不是Python库,因此无法通过requirements.txt安装.

libsndfile1 isn't a Python library, so you can't install it via requirements.txt.

一种可行的方法是使用 apt buildpack Python buildpack:

One way to get this working is to use the apt buildpack alongside the Python buildpack:

  1. 从您的requirements.txt

配置您的应用程序以使用两个buildpack:

Configure your application to use two buildpacks:

heroku buildpacks:set heroku/python
heroku buildpacks:add --index 1 heroku-community/apt
heroku buildpacks
# Should show apt first, then python

  • 添加 Aptfile 列出要安装的Ubuntu软件包已安装:

  • Add an Aptfile listing Ubuntu packages to be installed:

    libsndfile1
    

  • 提交更改并推动部署.您应该先安装apt软件包,然后再进行常规的Python部署.

  • Commit your changes and push to deploy. You should see apt packages installed first, then your regular Python deployment.

    这篇关于如何在Heroku上使用声音文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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