title: I am getting "OSError: sndfile library not found" & "Unable to locate package libsndfile1" errors when deploying audio prediction model on Heroku
body: <p>The objective is to deploy an audio prediction ML model on Heroku, which uses librosa library from python.</p>
  <p>The app.py file uses librosa library to extract features from the audio.</p>
  <p>When I try to deploy on Heroku, I get an error as shown below.</p>
  <pre><code>2020-06-12T03:27:43.099874+00:00 app[web.1]:   File &quot;/app/.heroku/python/lib/python3.6/site-packages/librosa/core/audio.py&quot;, line 10, in &lt;module&gt;
  2020-06-12T03:27:43.099875+00:00 app[web.1]:     import soundfile as sf
  2020-06-12T03:27:43.099875+00:00 app[web.1]:   File &quot;/app/.heroku/python/lib/python3.6/site-packages/soundfile.py&quot;, line 142, in &lt;module&gt;
  2020-06-12T03:27:43.099876+00:00 app[web.1]:     raise OSError('sndfile library not found')
  2020-06-12T03:27:43.099876+00:00 app[web.1]: OSError: sndfile library not found
  2020-06-12T03:27:43.101008+00:00 app[web.1]: [2020-06-12 03:27:43 +0000] [11] [INFO] Worker exiting (pid: 11)
  2020-06-12T03:27:43.255623+00:00 app[web.1]: [2020-06-12 03:27:43 +0000] [4] [INFO] Shutting down: Master
  2020-06-12T03:27:43.255725+00:00 app[web.1]: [2020-06-12 03:27:43 +0000] [4] [INFO] Reason: Worker failed to boot.
  2020-06-12T03:27:43.333827+00:00 heroku[web.1]: Process exited with status 3
  2020-06-12T03:27:43.371190+00:00 heroku[web.1]: State changed from starting to crashed
  </code></pre>
  <p>Here is a snapshot of my buildpacks that I am using to install the dependencies:
  <a href="https://i.stack.imgur.com/R2nVm.png" rel="nofollow noreferrer">Build pack list</a></p>
  <p>Below is the list of dependencies mentioned in requirements.txt:</p>
  <pre><code>Flask==1.1.1
  gunicorn==19.9.0
  itsdangerous==1.1.0
  Jinja2==2.10.1
  MarkupSafe==1.1.1
  Werkzeug==0.15.5
  numpy&gt;=1.9.2
  scipy&gt;=0.15.1
  scikit-learn&gt;=0.18
  matplotlib&gt;=1.4.3
  pandas&gt;=0.19
  librosa==0.7.2
  aniso8601==8.0.0
  audioread==2.1.5
  </code></pre>
  <p>I have also created an Aptfile to install libsndfile1. I have linked a build-pack on Heroku to install from this Aptfile. Below is the list mentioned in my Aptfile:</p>
  <pre><code>libsndfile1
  libsndfile-dev
  libasound2-dev 
  python-dev 
  python-numpy 
  python-setuptools 
  </code></pre>
  <p>Here is the image of error <a href="https://i.stack.imgur.com/tswjn.png" rel="nofollow noreferrer">&quot;Unable to locate package libsndfile1&quot;</a> while deploying on Heroku</p>
  <p>How to overcome the &quot;OSError: sndfile library not found&quot; and &quot;Unable to locate package libsndfile1&quot; errors?</p>
  <p>I have uploaded all the files to GitHub <a href="https://github.com/SughoshKulkarni/Bird-Predictor" rel="nofollow noreferrer">here</a> for more information.</p>
  <hr />
  <p><strong>Update (12/14/2020)</strong>: I changed my Aptfile and requirements.txt contents, and it worked.</p>
  <p>Here are the contents of Aptfile:</p>
  <pre><code>libsndfile1
  libsndfile-dev
  ffmpeg
  </code></pre>
  <p>Here are the contents of Aptfile:</p>
  <pre><code>aniso8601==8.0.0
  audioread==2.1.8
  certifi==2019.11.28
  cffi==1.14.0
  Click==7.0
  decorator==4.4.2
  ffmpeg-python==0.2.0
  Flask==1.1.1
  Flask-RESTful==0.3.8
  future==0.18.2
  gunicorn==20.0.4
  itsdangerous==1.1.0
  Jinja2==2.11.1
  joblib==0.14.1
  librosa==0.7.2
  llvmlite==0.31.0
  MarkupSafe==1.1.1
  marshmallow==3.2.2
  numba==0.48.0
  numpy==1.18.1
  pycparser==2.20
  pydub==0.23.1
  pytz==2019.3
  resampy==0.2.2
  scikit-learn==0.22.2.post1
  scipy==1.4.1
  six==1.14.0
  SoundFile==0.10.3.post1
  Werkzeug==1.0.0
  wincertstore==0.2
  pandas==1.0.1
  pathlib==1.0.1
  </code></pre>