Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
281 views
in Technique[技术] by (71.8m points)

python - How to use soundfile on 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')

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:

No matching distribution found for libsndfile1

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

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

  1. Remove libsndfile1 from your requirements.txt

  2. 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
    
  3. Add an Aptfile listing Ubuntu packages to be installed:

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...