如何在Heroku上使用声音文件 [英] How to use soundfile on 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:
-
从您的
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屋!