Issue
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!! :)
Solution
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:
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
Answered By - S.H.
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.