I'm trying to get Librosa working with python.
Originally I had Python 2.7 installed, I wasn't able to get Librosa working with Python 2.7 so I installed Anaconda (which I've never used before) so that I could have a separate environment (to allow my old programs written in 2.7 to continue to work). I'm trying to use Jupyter notebook which I've also never used before and I finally managed to import Librosa after creating an Anaconda environment with Python 3.6, however I'm not able to import librosa.display
When I googled "importing Librosa.display" apparently I need to install matplotlib first, however importing matplotlib is failing and I'm not sure why. I think it might be failing due to importing PIL /pillow? however I've never specifically used that module before or had to install it separately when using matplotlib so I'm not sure why it's needed.
I tried reinstalling pillow using PIP install in the anaconda python3.6 environment that I created but it didn't work so now stuck and just wondering if anyone can help me?
for the import code as follows
import matplotlib
import librosa
import matplotlib.pyplot as plt
import librosa.display
The program gets stuck on "import matplotlib.pyplot as plt" and the error message I currently have is as follows (prior to reinstalling pillow it didn't work but the message was different):
C:\Users\sh\.conda\envs\signalprocess1\lib\site-packages\PIL\Image.py:130: RuntimeWarning: The _imaging extension was built for another version of Pillow or PIL:
Core version: 8.2.0
Pillow version: 8.1.2
warnings.warn(str(v), RuntimeWarning)
C:\Users\sh\.conda\envs\signalprocess1\lib\site-packages\matplotlib\mathtext.py in <module>()
25
26 import numpy as np
---> 27 from PIL import Image
28 from pyparsing import (
29 Combine, Empty, FollowedBy, Forward, Group, Literal, oneOf, OneOrMore,
C:\Users\sh\.conda\envs\signalprocess1\lib\site-packages\PIL\Image.py in <module>()
111 if __version__ != getattr(core, "PILLOW_VERSION", None):
112 raise ImportError(
--> 113 "The _imaging extension was built for another version of Pillow or PIL:\n"
114 f"Core version: {getattr(core, 'PILLOW_VERSION', None)}\n"
115 f"Pillow version: {__version__}"
ImportError: The _imaging extension was built for another version of Pillow or PIL:
Core version: 8.2.0
Pillow version: 8.1.2
Any help would be great. I don't need to use Jupyter I'm perfectly happy using IDLE if IDLE will work with Librosa and matplotlib through Python 3.6. All I want to do is get Librosa and Matplotlib working so I can analyse signals! I guess if I spend another couple of days on it I'll work it out eventually but it's very annoying spending all this time just trying to get the packages working before I even get to the signal analysis.
thanks!! :)
I'm not sure what I was doing wrong.....
however in the end I got librosa working with anaconda python 3.8 and jupyter on Windows 10 (64) as follows...
Uninstalled anaconda (possibly it wasn't necessary to uninstall it - not sure)
Uninstalled jupyter the best I could (still seemed to be some remnants associated with arcpy)
Installed miniconda the python 3.8 version
Created a new (separate) Conda environment which also used python 3.8
This was done by opening the Conda command prompt then typing......
conda create --name signalpro38 python=3.8
(note that signalpro38 is the name I gave the new environment)
activated the new environment by typing:
conda activate signalpro38
Installed:
matplotlib,
scipy,
numba,
numpy
then
jupyter
into the new environment (signalpro38)
by typing
conda install matplotlib
conda install scipy
etc.
Added the new anaconda environment to jupyter by following the instructions here:
https://medium.com/#nrk25693/how-to-add-your-conda-environment-to-your-jupyter-notebook-in-just-4-steps-abeab8b8d084
opened jupyter and created a new notebook (making sure to choose the name of the new environment signalpro38)
typed code into the new notebook, saved and ran it, to check that the commands
import matplotlib
and
import matplotlib.pyplot as plt
were working ok in jupyter
Closed jupyter and went back to the Conda command prompt (the signalpro38 environment that I had created was still activated)
then installed librosa using
pip install librosa
(note that "conda install librosa" didn't find librosa, however I imagine there is a way to install librosa using conda also)
opened jupyter again and the previously saved notebook file and added
import librosa
import librosa.display
all seems to be working well now! :)
Hopefully this will help someone else! most likely it will help me when I need to do this again one day! :p
I keep getting the error: ModuleNotFoundError: No module named 'seaborn'
when trying to import seaborn.
I have installed seaborn using both pip install seaborn and conda install seaborn.
I saw on seaborn that I am not the only one who has had this issue, but I have not been able to resolve this problem, how can I check and updated that my pip/conda points to the same installation as my interpreter?
EDIT:
I have tried running !pip install seaborn in the notebook, but this still does not work. I have also created my own conda env and installed seaborn (it shows base in the photos) but this also did not work.
you might have an old version of Jupyter notebook, so need to try this command to install it in the current kernel.
import sys
!{sys.executable} -m pip install seaborn
In the New Jupyter version (2019) can be installed simply as:
%pip install seaborn
Note: Answer from different question!
So I deleted and reinstalled the most up to date version of Anaconda Navigator with Python 3.6 on Windows 10. I launched Jupyter notebook and tried to import
1, numpy,
2, matplotlib
and 3, pandas
It was able to import Numpy and Matplotlib but for Pandas it gave me a very long error message as follows. I also use a Mac computer and it seems no problem with importing pandas using the Jupyter Notebook.
from the error message it seems that Pandas is not on of the pre-installed libraries in the Anaconda that you installed. It is the not the problem with the OS. Run the following command:
conda install -c anaconda pandas
then run the import statement.
I am running the following code:
import pandas as pd
import matplotlib.pyplot as plt
from matplotlib import style
style.use('ggplot')
web_stats = {"Day":[1,2,3,4,5,6],
"Visitors":[43,53,34,45,64,34],
"Bounce_Rate":[65,72,62,64,54,66]}
df = pd.DataFrame(web_stats)
print(df)
It works just fine for me in the Jupyter notebook. But I am getting errors when I try to run it on IDLE, and I am wondering how to make it work there, too.
Here are the errors I'm getting:
Traceback (most recent call last):
File "C:\Users\theca\AppData\Local\Programs\Python\Python35-32\pandas.py", line 1, in
import pandas as pd
File "C:\Users\theca\AppData\Local\Programs\Python\Python35-32\pandas.py", line 2, in
import matplotlib.pyplot as plt
ImportError: No module named 'matplotlib'
I am new to Python, please to help. Thanks!
This is a duplicate of similar questions. The question is not really about IDLE, but about having multiple versions of python installed, or the same version installed more than once. The answer is that you have to install packages for each python executable that you want to use them with.
You traceback says that you ran IDLE with "C:\Users\theca\AppData\Local\Programs\Python\Python35-32" and that pandas is installed with it, started to run, tried to import matlib.pyplot as plt, and failed. You need to install matlib with the same python. Try
C:\Users\theca\AppData\Local\Programs\Python\Python35-32 -m pip install matlib
Have you actually installed pandas and matplotlib?
Your best bet would be to install Anaconda, which automatically installs some useful Python libraries for you.
If you don't want to install so many unnecessary libraries, you can install pandas via pip: pip install pandas, and matplotlib by pip install matplotlib. If you use pip you may have to install dependencies, so up to you.
EDIT: Your paths may also be setup wrongly. Check if the libraries are installed under the correct folder, C:\Users\theca\AppData\Local\Programs\Python\Python35-32\pandas.py, for example here. If not, you either have to move them or setup the path in python, like this:
import sys
sys.path.append("<the install path here>")
import pandas
I had the same problem : it is indeed a problem of having different versions of python installed. If your Idle is working with python 3.5, then you just have to do
pip3.5 install matplotlib
I think it is because you used Anaconda to install pandas and matplotlib. Thus, these two modules are installed only in Anaconda virtual environments. The Python IDLE cannot find modules in virtual env, it only search modules located in system paths.
So, you need to reinstall these modules in Windows cmd rather than Anaconda if you insist to use Python IDLE.
1. win + r
2. input cmd
3. pip install pandas, matplotlib
In all, I recommend to use Anaconda and the IDE in it named Spyder.
It appears as if you don't have matplotlib installed on your system.
Go to the command prompt and type the following (if you are using windows)-
py -m pip install matplotlib
py -m pip install pandas
Then try the your code again.
import os
try:
import Pandas as pd
except ImportError as e:
e = str(e)[15:]
e = e.strip().replace("'", "")
os.system('py -m pip install %s' % (e))
Try above code. In window cmd you have to type py and they python code or module to run it from cmd.
from matplotlib import pyplot as plt
import pandas as pd
web_stats = {"Day":[1,2,3,4,5,6],
"Visitors":[43,53,34,45,64,34],
"Bounce_Rate":[65,72,62,64,54,66]}
df = pd.DataFrame(web_stats)
df.plot(grid=True)
plt.show()
You can try above code. It works.
Installing Python Pandas on Windows With pip:
1- you should head over to our terminal or command prompt from where you can install Pandas. So go to your search bar on your desktop and search for cmd. An application called Command prompt should show up
2- and immediately Type in the command "pip install pandas". Pip is a package install manager for Python and Wait for the downloads to be over and once
3- you can type "import pandas as pd" in IDLE
4- and congratulations! you have pandas and other lib with this way:).
I'm using spyder (python2.7) on a macbook for my data analysis
import seaborn as sis
but when I run:
ImportError: No module named seaboard
I installed seaborn using conda install seaborn and also pip2.7, but still having trouble in spyder. If run in terminal as python2.7 file.pyit works, so I guess I'm not able to import seaborn correctly in spyder.
PS:
I've also tried adding the right path where the package is located into python path manager.....
Thank you very much
Conda install:
http://conda.pydata.org/miniconda.html
conda install seaborn
You should use conda for easy step, or follow this tutorial:
https://stanford.edu/~mwaskom/software/seaborn/installing.html