Python Forum
Installing and Using Seaborn
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Installing and Using Seaborn
#1
I am on Windows 10 with professional edition. I have tried to install seaborn several times. It installs.

But in a program when I have a line that says:

import seaborn I also get a long error that states:

ImportError                               Traceback (most recent call last)
Input In [3], in <cell line: 1>()
----> 1 import seaborn

File ~\miniconda3\envs\pump-failure-prediction\lib\site-packages\seaborn\__init__.py:2, in <module>
      1 # Import seaborn objects
----> 2 from .rcmod import *  # noqa: F401,F403
      3 from .utils import *  # noqa: F401,F403
      4 from .palettes import *  # noqa: F401,F403

File ~\miniconda3\envs\pump-failure-prediction\lib\site-packages\seaborn\rcmod.py:5, in <module>
      3 import functools
      4 from distutils.version import LooseVersion
----> 5 import matplotlib as mpl
      6 from cycler import cycler
      7 from . import palettes

File ~\miniconda3\envs\pump-failure-prediction\lib\site-packages\matplotlib\__init__.py:109, in <module>
    105 from packaging.version import parse as parse_version
    107 # cbook must import matplotlib only within function
    108 # definitions, so it is safe to import from it here.
--> 109 from . import _api, _version, cbook, docstring, rcsetup
    110 from matplotlib.cbook import MatplotlibDeprecationWarning, sanitize_sequence
    111 from matplotlib.cbook import mplDeprecation  # deprecated

File ~\miniconda3\envs\pump-failure-prediction\lib\site-packages\matplotlib\rcsetup.py:27, in <module>
     25 from matplotlib import _api, cbook
     26 from matplotlib.cbook import ls_mapper
---> 27 from matplotlib.colors import Colormap, is_color_like
     28 from matplotlib.fontconfig_pattern import parse_fontconfig_pattern
     29 from matplotlib._enums import JoinStyle, CapStyle

File ~\miniconda3\envs\pump-failure-prediction\lib\site-packages\matplotlib\colors.py:51, in <module>
     49 from numbers import Number
     50 import re
---> 51 from PIL import Image
     52 from PIL.PngImagePlugin import PngInfo
     54 import matplotlib as mpl

File ~\miniconda3\envs\pump-failure-prediction\lib\site-packages\PIL\Image.py:89, in <module>
     80 MAX_IMAGE_PIXELS = int(1024 * 1024 * 1024 // 4 // 3)
     83 try:
     84     # If the _imaging C module is not present, Pillow will not load.
     85     # Note that other modules should not refer to _imaging directly;
     86     # import Image and use the Image.core variable instead.
     87     # Also note that Image.core is not a publicly documented interface,
     88     # and should be considered private and subject to change.
---> 89     from . import _imaging as core
     91     if __version__ != getattr(core, "PILLOW_VERSION", None):
     92         raise ImportError(
     93             "The _imaging extension was built for another version of Pillow or PIL:\n"
     94             f"Core version: {getattr(core, 'PILLOW_VERSION', None)}\n"
     95             f"Pillow version: {__version__}"
     96         )

ImportError: DLL load failed while importing _imaging: The specified module could not be found.
I have no idea what this means. I have pip uninstalled seaborn and pip installed seaborn
I have also conda uninstalled seaborn and conda install seaborn.

Nothing changes. It is still the same error that I have shown above.

I just do not know what is causing this error. That is the reason for this post.

Any help appreciated.

Respectfully,

LZ
Reply
#2
Downgrade Pillow to 8.0.0.
How To Fix The Python Pillow Error ImportError: DLL load failed while importing _imaging
Reply
#3
I believe that your solution to downgrade pillow is the correct one. However, it is hard to remove pillow ver 9.0.1 which is what I have now.

In this correct environment on jupyter notebook even after pip uninstall pillow and pip install pillow==8.0.0, I still get pillow=9.0.1 when I run pip show pillow. It still says pillow=9.0.1 when it should say no module found. I am not sure why.

If I run it on the command line and in the correct environment it will say pip = 8.0.0 after I remove pillow and install pillow=8.0.0. This is what it should say when I run it in Jupyter notebook, but there it says pillow=9.0.1.

The only solution that I can think of is remove the environment that keeps saying pillow=9.0.01 when I run it in jupyter notebook. Then rebuild that environment, but that is a major undertaking.

Are there any shorter solutions? Thanks in advance.

Respectfully,

LZ
Reply
#4
I think that I see the problem here. On my desktop computer with windows 10, I have two virtual environments.

The first is my base environment, it was created when I installed Jupyter notebook the first time. The second item that I created was a second virtual environment for my specific project of predicting pump failure I installed no Jupyter notebook in it.

I then went about installing modules according to what I think that I will need to do this project correctly. I did not directly install pillow, it must have been installed as a supporting module when I installed another module. The version of pillow was 9.0.1.

When I tried to run a small section of my program, it crashed when I tried to import seaborn. It just would not import seaborn.

Now when I was told in this post that (see above) I must downgrade pillow to 8.0.0. I did this to allow seaborn to be imported. I did it in the correct environment which was my second created environment not the base environment. These two environments were basically the same, except to base environment had pillow=9.0.1 and my specialized environment had pillow=8.0.0.

Please note that installed Jupyter notebook only once in the base environment. I installed one time and used it for access to all of my environments; there are only two. If I wanted to get to the specialized environment I typed Jupyter notebook in the base environment and then switched to the next more specialized environment in the upper left hand corner of the Jupyter notebook IDE.

I thought that I was saving hard drive space, by only installing Jupyter notebook one and then accessing all virtual environments from the upper left hand corner for the IDE as I said.

This may save hard drive space, but it does create problems. It seems that the base environment apps or modules bled over into the specialized environment.

That is why that even though I wanted pillow 8.0.0 in the specialized environment, in the Jupyter notebook IDE I got the pillow that was 9.0.1.

I am not sure why, but I beleive that one must install Jupyter notebook in each virtual environment that one intends to use it.

Is there an easier alternative?

Respectfully,

LZ
Reply
#5
(Jun-07-2022, 08:24 PM)Led_Zeppelin Wrote: I am not sure why, but I beleive that one must install Jupyter notebook in each virtual environment that one intends to use it
Yes.
(Jun-07-2022, 08:24 PM)Led_Zeppelin Wrote: Is there an easier alternative?
Fix it he environment you use Jupyter Notebook from.
It's common to have many environment i have lot,one main that that i use most and also plain OS install of python.org/Anaconda//Miniconda/PyPy...ect
I have many because i test out stuff and also help people with install problems here on forum.
When there is a project that install a lot packages i usually make new environment to avoid conflicts.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Trying to loop through code to plot seaborn line plots across multiple subplots eyavuz21 0 1,693 Dec-05-2022, 10:46 AM
Last Post: eyavuz21
  How to plot seaborn heatmap on top of a background circle SriRajesh 0 1,424 Jul-09-2022, 04:00 AM
Last Post: SriRajesh
  titanic from Seaborn matador 3 4,674 Aug-20-2020, 12:13 PM
Last Post: buran
  seaborn scatterplot npiatti 1 1,898 Mar-03-2020, 01:54 PM
Last Post: scidam
  y-axis on seaborn heatmap not aligned properly amjass12 0 2,848 Oct-01-2019, 10:37 AM
Last Post: amjass12
  How to manually define color bar scale in seaborn heatmap SriRajesh 3 18,342 Sep-08-2019, 11:12 AM
Last Post: RudraMohan
  How to plot multiple scatter plots in seaborn vikola 2 6,510 Jul-14-2019, 10:30 AM
Last Post: vikola

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020