Problem with importing librosa on Jupyter notebook

1,277 views
Skip to first unread message

Eylul Erler

unread,
May 13, 2021, 11:21:40 AM5/13/21
to librosa
Hi everyone,

I'm new to Python and I need to use librosa for my project about sound analysis. I'm having trouble with importing librosa on Jupyter notebook. I'm pretty sure I installed it correctly. All the other library imports work but when I try to import librosa, the notebook does not execute it and [*] mark always stays. When I stop execution, this show up.
librosaerror.png

Any idea why I get this? 

Brian McFee

unread,
May 13, 2021, 11:28:07 AM5/13/21
to librosa
I think the problem here is coming from numba, which we use to compile some functions at load-time for efficiency.  Numba will want to save the compiled objects in the same place as the module, but if you don't have write permission to that location (eg because it's an administrator-installed package), that would cause this error.

The "easiest" way to work around this is to set an environment variable prior to importing librosa which will change numba's cache directory (see https://numba.pydata.org/numba-doc/dev/reference/envvars.html#envvar-NUMBA_CACHE_DIR )

Something like:

import os
import IPython
os.environ['NUMBA_CACHE_DIR'] = IPython.paths.get_ipython_cache_dir()
import librosa

ought to do the trick.

Eylul Erler

unread,
May 13, 2021, 11:45:48 AM5/13/21
to librosa
It works, thank you so much Brian!

Best Regards

13 Mayıs 2021 Perşembe tarihinde saat 18:28:07 UTC+3 itibarıyla Brian McFee şunları yazdı:
Reply all
Reply to author
Forward
0 new messages