question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

import librosa causes flask app on IIS to 500

See original GitHub issue

BEFORE POSTING A BUG REPORT Please look through existing issues (both open and closed) to see if it’s already been reported or fixed!

Describe the bug import librosa causes flask app on iis to timeout and return 500

To Reproduce Not going to put all the steps here to set up a flask app on IIS/Windows but generally something like this: https://medium.com/@dpralay07/deploy-a-python-flask-application-in-iis-server-and-run-on-machine-ip-address-ddb81df8edf3

#somewhere in the app have the following
import librosa

Your app will hang indefinitely until timeout, forcing webserver to report 500

Expected behavior librosa loads without issue

Screenshots

Software versions* Windows-10-10.0.20348-SP0 Python 3.10.7 (tags/v3.10.7:6cc6b13, Sep 5 2022, 14:08:36) [MSC v.1933 64 bit (AMD64)] NumPy 1.23.3 SciPy 1.9.1 librosa 0.9.2 INSTALLED VERSIONS

python: 3.10.7 (tags/v3.10.7:6cc6b13, Sep 5 2022, 14:08:36) [MSC v.1933 64 bit (AMD64)]

librosa: 0.9.2

audioread: 3.0.0 numpy: 1.23.3 scipy: 1.9.1 sklearn: 1.1.2 joblib: 1.2.0 decorator: 5.1.1 soundfile: 0.10.3 resampy: 0.4.2 numba: 0.56.2 pooch: v1.6.0 packaging: 21.3

numpydoc: None sphinx: None sphinx_rtd_theme: None sphinx_multiversion: None sphinx_gallery: None mir_eval: None ipython: None sphinxcontrib-svg2pdfconverter: None pytest: None pytest-mpl: None pytest-cov: None matplotlib: None samplerate: None soxr: None contextlib2: None presets: None

Additional context This is a difficult issue to trouble shoot because I am seeing no related errors in trace files nor logs from IIS. I’ve narrowed it down to exactly librosa though. I can comment out a librosa import and everything runs, but if I attempt to import the webpage will spin until it times out and returns a 500.

Environment is python 3.10, librosa was installed with pip. No virtual env at this time, only one python installion. Windows server 2019, IIS 10 (using fastcgi/wfastcgi.py as handler).

I’ve tested to see if an exception is being thrown but it does not appear so (the except of a try except does not appear to trigger, it simply hangs on trying to import librosa).

I’ve tested librosa independent of the flask/IIS context and it loads fine. FFMPeg is in path, audio analysis functions work fine.

I’m confident this has something to do with librosa need some environment variable/setting that is not being picked up by the IIS context, but for the life of me I can’t figure out what that would be. I suspect this because I can force the IIS application pool to run as my login and it will work, but if I have it run as apppool then it fails. Only librosa fails to import running as apppool, every other aspect of the app works (and there are a lot of imports, from pydodbc, to pandas, to plotting pacakges, to numpy and sklearn and even some installed directly from github and custom ones not publicly availalble. It seems librosa needs some sort of environment variable to load?

Any assistance or leads would be appreciated.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:10 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
ebachuracommented, Sep 23, 2022

I’ve figured this out! I was reading through other issues and happened across this one (Number 987):

https://github.com/librosa/librosa/issues/987

The fix recommended by a5467021 is indeed the fix. Granting write/read to users on the librosa library fixes the issue. Thanks for the help!

1reaction
bmcfeecommented, Sep 21, 2022

Again, I can make it work by forcing the application to run as my local account, but any of the built in (local system, local service, network service, applicaitonidentity) and it fails.

Ah, I’d missed this on the first read-through. You said you installed via pip, but I guess it’s possible that pip installed as a user instead of the system. This is really where a virtual environment / container would be most helpful btw.

Where would I need to give permissions regarding this track registry thing you mention?

Not sure on windows, sorry. You’ll need to locate where librosa installed (eg print(librosa.__file__) and make sure your web server has access to read from that location.

Also, I would have expected a file access is to throw an exception, not cause it to hang…it’s not throwing an exception, which is why I’m on the struggle bus atm.

Yep, that sure sounds weird. But web servers do sometimes do funny things like catch-all exception handlers. 🤷

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error 500 while running a Python Flask application on IIS ...
I got it running on my development machine. But it doesn't work in the actual production environment. I get a error 500 for...
Read more >
Deploy a Python Flask Application in IIS Server and run on ...
To run a flask application in IIS server, we need the “flask” and “wfastcgi” libraries. ... """from flask import Flaskapp = Flask(__name__)
Read more >
How To Handle Errors in a Flask Application - DigitalOcean
In the above code, you first import the Flask class from the flask package. Then you create a Flask application instance called app...
Read more >
import arcgis in Flask with fastcgi in IIS - Esri Community
I kept getting a 500 error with the import ArcGIS statement. Running it in flask without fastCGI works fine. arcgispro-py3\python.exe - The ...
Read more >
Python Flask on IIS with wfastcgi - gists · GitHub
However I am getting HTTP 500 error with " scriptProcessor could not be found in application configuration". Is this a Python version issue?...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found