6

Currently I am working on voice recognition where I wanted to use Librosa library.

I install librosa with the command on ubuntu:

conda install -c conda-forge librosa

But when I run the code I got the following error:

import librosa


  

ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-9-989066361697> in <module>
----> 1 import librosa

ModuleNotFoundError: No module named 'librosa'

Can anyone tell me how to use librosa?

Wwe Cena
  • 112
  • 1
  • 1
  • 7
  • Run "which python" on your console and see that it is loading the right one. If conda is installing in one location, but you're calling another Python when you run "import", this would cause the error you observe. – Hayden Eastwood Jun 30 '20 at 13:33
  • /home/subhash/anaconda3/bin/python – Wwe Cena Jun 30 '20 at 13:59
  • and are you sure this is where conda is installing? Try doing "which conda" also – Hayden Eastwood Jun 30 '20 at 14:54
  • subhash@subhash-Inspiron-3558:~$ which python /home/subhash/anaconda3/bin/python subhash@subhash-Inspiron-3558:~$ which conda /home/subhash/anaconda3/bin/conda ..... my conda path is ...... /home/subhash/anaconda3/lib/python3.7/site-packages/conda.... – Wwe Cena Jun 30 '20 at 15:11
  • very strange. Have you tried installing it without conda? just use pip3 install and see if that works? – Hayden Eastwood Jun 30 '20 at 15:53
  • I am on a mac so I can't reproduce this problem, much as I have tried. – Hayden Eastwood Jun 30 '20 at 16:05
  • ModuleNotFoundError: No module named 'numba.decorators' ..... with pip3.....I didn't understand what u want to say – Wwe Cena Jun 30 '20 at 16:08
  • okkk... when I installed librosa it goes to python3.8.... How to get rid of it? – Wwe Cena Jun 30 '20 at 16:37
  • so therein lies the issue - there is indeed a path conflict. Try setting up a virtual environment to solve it. Check out: https://www.pythonforbeginners.com/basics/how-to-use-python-virtualenv/ – Hayden Eastwood Jun 30 '20 at 19:44
  • Restarting Anaconda worked for me. – S.P. Mar 29 '21 at 15:23

5 Answers5

6

If you’re using a Python 3.5 environment in conda, you may run into trouble with the numba dependency. This can be avoided by installing from the numba conda channel before installing librosa:

Run this command first in anaconda prompt

conda install -c numba numba

and then

conda install -c conda-forge librosa

I hope this would help you

Ritik Kumar
  • 661
  • 5
  • 16
2

There are two solutions,

  1. Try to install librosa by system:

*. First open cmd in system and try one of following commands.

pip install librosa

sudo pip install librosa

pip install -u librosa

  1. Or in conda environment:

*. Open appropriate anaconda prompt(according to environment) and try following commands inorder,

First, conda install -c numba numba

Then, conda install -c conda-forge librosa

0

What I did

I had a similar problem. I had to use the following code:

sys.path.append(r"C:{pathtopython}\Lib\site-packages")

Assuming you downloaded librosa to the path above, then the program will be able to find librosa and use it.

Why it Works/Why it Happened

It works because the program is looking in a directory that the package isn't in.

All my other packages were able to be found by my program without using the code above, so I think it's related to the librosa installation.

0

Do pip install librosa --user and then restart Anaconda.

Paul Roub
  • 36,322
  • 27
  • 84
  • 93
S.P.
  • 185
  • 19
-1

It did not work for me also and I received the same error. Then I cut and pasted the entire code to a new SPYDER document and it worked. Not sure why it did not work the first time in SPYDER. But try pasting into a new SPYDER file and see what happens.

bad_coder
  • 11,289
  • 20
  • 44
  • 72