ModuleNotFoundError: No module named 'librosa' - python

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?

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

There are two solutions,
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
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

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.

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

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.

Related

python library install Questions

I use Python and pycharm as a tool.
If you use the pip statement to install the library, you will get an error.
For example, if I want to download the torch (1.6.0) version and type pip install torch==1.6.0,
It says no version.
This is not the end, but some libraries continue to cause strange conflicts and will not be installed.
For example, if you type pip install poro to install the poro library, an unknown error pops up and the installation fails.
I'm not asking for a pororo installation.
My question is, I want to know how to download the library without relying on pycharm.
I want to download it separately from a site like pypi and put the library directly into the virtual environment (conda).
What should I do?
The following worked for me:
First, install mkl using conda:
conda install -c anaconda mkl
Then run this:
conda install -c pytorch pytorch

How to install package import_ipynb with anaconda?

I take jupyter notebook with this line in the import :
import import_ipynb
When I run the notebook iI got the error :
ModuleNotFoundError: No module named 'import_ipynb'
I try to install with anaconda :
conda install import_ipynb
or
conda install import-ipynb
But it dont find the package, but with pip I got no problem :
pip install import_ipynb
Any idea with anaconda ?
Thanks !
It looks like that "package" - really, it's just a script - doesn't properly list it's dependencies in setup.py. I also can install it from pip, but it shows it can't load because it references nbformat. Using
conda install nbformat
get's it working for me.
Recommendation
I don't know this package space, but it seems like nbimport is a far more mature solution for such functionality. It is available on Conda Forge (conda install -c conda-forge nbimport) and appears to be quite popular (> 20K downloads).

Why ImportError: No module named lightgbm

My OS is Ubuntu, and I've followed the official installation guide to install lightgbm. However, when I import it, this error is raised:
ImportError: No module named lightgbm
How can I solve this?
Do I also need to go to /python-package folder to run setup.py after running those linux commandlines?
I had the same problem, and solved running the installation directly on the notebook
!pip install lightgbm
Besides running those linux command lines. I also need to go to /python-package then run 'python setup.py install'.
conda install -c conda-forge lightgbm solved the problem for me
you need just run in a notebook cell before importing
For Windows users, VC runtime <https://go.microsoft.com/fwlink/?LinkId=746572> is needed if Visual Studio (2015 or 2017) is not installed.
Install wheel <http://pythonwheels.com> via pip install wheel first. After that download the wheel file and install from it:
pip install lightgbm
The following should do the trick:
export PATH=/usr/local/bin/anaconda3/bin${PATH:+:${PATH}}
PYTHONPATH=$PYTHONPATH:/usr/local/bin/anaconda3/lib/python3.6/site-packages
Note that you might need to change the paths if you are using a different Python version.
Thank you for above question and answers, had a similar issue.
Problem:
After successfull install of lightgbm, I was getting the error ImportError: No module named 'lightgbm' (in Jupyter Notebook on Google Cloud's Notebook Instance in AI Platform project).
Issue:
Realized that the install of lightgbm was in Python 2.7 even when the notebook was running in Python 3 (path: './.local/lib/python2.7/site-packages').
Solution:
The error was gone after the Jupyter Notebook was set to run on Python 2 instead of Python 3.
within Jupyter Notebook cell is: try running
import sys
!{sys.executable} -m pip install lightgbm
With python try, from pypi.org, this line
pip install lightgbm
or
pip3 install lightgbm
Also, you can try this one if you use anaconda
conda install lightgbm

How to install gensim on windows

Not able to install gensim on windows.Please help me I need to gensim Immediately and tell me installation steps with More details and other software that needs to be installed before it. thanks
First you need to install NumPy then SciPy and then Gensim (assuming you already have Python installed). I used Python 3.4 as I find it easier to install SciPy using version 3.4.
Step 1) Install Numpy:
Download numpy‑1.13.1+mkl‑cp34‑cp34m‑win32.whl from here
note that in cp34-cp34m 34 is version of Python you are using. So download appropriate file
Open command prompt and go the folder in which you just downloaded the file and install Numpy using following command:
pip install numpy‑1.13.1+mkl‑cp34‑cp34m‑win32.whl
You should get successfully installed numpy message
Step 2) Install SciPy:
Follow the same link as above and download the scipy‑0.19.1‑cp34‑cp34m‑win32.whl file.
Install it using the same instructions than in Step 1 but with this file name. The command is the following:
pip install scipy‑0.19.1‑cp34‑cp34m‑win32.whl
You should get this message successfully installed scipy
Step 3) Install gensim:
Follow the link in step 1 and download gensim‑2.3.0‑cp34‑cp34m‑win32.whl (the appropriate version for your system)
Install it using the instructions in Step 1 (with this file name) with following command:
pip install gensim‑2.3.0‑cp34‑cp34m‑win32.whl
You should get this message successfully installed gensim
Now in a Python shell try:
import gensim
It should be successfully imported
NOTES:
Make sure pip is in your environment variables (add C:\python34\scripts to your environment variable).
Make sure to download all the packages according to the Python version you are using.
gensim depends on scipy and numpy.You must have them installed prior to installing gensim. Simple way to install gensim in windows is, open cmd and type
pip install -U gensim
Or download gensim for windows from
https://pypi.python.org/pypi/gensim
then run
python setup.py test
python setup.py install
I struggled with this a bit today trying to figure out if I needed a python 2.7 environment or if I could use my 3.5. I ended up doing this from an Anaconda 3.5 install:
conda install -c anaconda gensim=0.12.4
After a few hours of trying various things, suddenly it all worked on 3.5. My error was that it kept failing to install Scipy. I tried starting over with the conda install and just worked.
See: https://anaconda.org/anaconda/gensim
I strongly suggest using anaconda where the installation of all the packages is very easy.
The command for installing genism and all of its necessary packages on windows using anaconda python 3.7 is below.
conda install -c anaconda gensim
I followed the instruction on https://radimrehurek.com/gensim/install.html which then successfully installed the fast version of Gensim (3.8.0) on Windows:
conda install -c conda-forge gensim
PS:
The following did NOT install the fast version on Windows:
conda install gensim
After attempting some of the above ideas, there was still a "hiccup" with gensim but the error was something else related to punkt. The following (where the interest is the second line)...
import nltk
nltk.download('punkt')
import numpy
import scipy
import gensim
...did the trick. I used conda and not pip but do not believe that mattered.
Versions: latest python
Machine: Windows 10 (latest updates as of 8/2020)

ImportError: No module named 'pydub'

I am creating a simple script that will use pydub to fetch files from a directory based on their name, then stitch a few of them together and export the result.
I had the script working great in a Windows environment (Win 7, python 3.4), but now I'm trying to run on OSX.
I have installed all necessary components - ffmpeg, libav. I have just installed pydub with pip, pulling directly from github.
My file starts with the input statement from pydub import AudioSegment, and this is what I get:
Traceback (most recent call last):
File "functions.py", line 2, in <module>
from pydub import AudioSegment
ImportError: No module named 'pydub'
Thoughts? What am I missing? Any help is greatly appreciated!
Check out PEP 0394. You might be running $ python functions.py when you need to be running $ python3 functions.py. If that's the case, make sure you $ pip3 install pydub, otherwise OSX will not add the package to the right python version.
I got the same issue after installing the pydub vai:
pip install pydub
then I use both via pip and pip3 and error gone
pip 3 install pydub
pip install pydub
Try to install with pip3
pip3 install pydub
If you are using Python 2, just run
pip2 install pydub
Try running the below command in your terminal,
pip install pydub
for me none of the above worked. I had to completely delete all instances of anaconda.
All instances of python.
And then reinstall python and reinstall jupyter notebooks. And then it started working and the pydub package reinstalled and the import started working.

Categories

Resources