import librosa causes flask app on IIS to 500
See original GitHub issueBEFORE 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:
- Created a year ago
- Comments:10 (2 by maintainers)
Top GitHub Comments
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!
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.
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.Yep, that sure sounds weird. But web servers do sometimes do funny things like catch-all exception handlers. 🤷