Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cannot import name rcParams #1280

Closed
simon-r opened this issue Sep 19, 2012 · 23 comments
Closed

cannot import name rcParams #1280

simon-r opened this issue Sep 19, 2012 · 23 comments

Comments

@simon-r
Copy link

simon-r commented Sep 19, 2012

I've tried this demo from your website:
http://matplotlib.org/api/widgets_api.html?highlight=matplotlib.widgets#matplotlib.widgets.RectangleSelector

But at the moment of runnig your program I've this error:

File "rec.py", line 1, in
from matplotlib.widgets import RectangleSelector
File "/usr/lib/python3.2/site-packages/matplotlib/init.py", line 105, in
import os, re, shutil, subprocess, sys, warnings
File "/usr/lib/python3.2/subprocess.py", line 378, in
import select
File "/home/simone/spz/select.py", line 1, in
from pylab import *
File "/usr/lib/python3.2/site-packages/pylab.py", line 1, in
from matplotlib.pylab import *
File "/usr/lib/python3.2/site-packages/matplotlib/pylab.py", line 222, in
from matplotlib import mpl # pulls in most modules
File "/usr/lib/python3.2/site-packages/matplotlib/mpl.py", line 1, in
from matplotlib import artist
File "/usr/lib/python3.2/site-packages/matplotlib/artist.py", line 6, in
from matplotlib import docstring, rcParams
ImportError: cannot import name rcParams

I'm using the GIT version with python 3 under ArchLinux.
But I've observed the same problem with matplotlb 1.1.1 on python 2

@efiring
Copy link
Member

efiring commented Sep 19, 2012

This is not a bug. The problem is that subprocess is trying to import the python library select module, but it is instead finding your own select.py, and that is trying to pull in all of pylab, while matplotlib.widgets was still in the early stages of importing matplotlib/init.py. You need to rename your select.py to avoid the name clash, or run from a different directory, or take spz out of your PYTHONPATH, if that is the way your select is being found.

@efiring efiring closed this as completed Sep 19, 2012
@santhoshav15
Copy link

OS: Ubuntu 16.04
Python Version: 3.5.2
Matplotlib Version: 3.0.2

When i try to from matplotlib import pyplot as plt

I am facing the same issue

Traceback (most recent call last):
File "try.py", line 2, in
from matplotlib import pyplot as plt
File "/home/artivatic/.virtualenvs/test/lib/python3.5/site-packages/matplotlib/init.py", line 124, in
import inspect
File "/usr/lib/python3.5/inspect.py", line 35, in
import dis
File "/home/artivatic/Documents/Santhosh/data/ori_data/dis.py", line 1, in
from matplotlib import pyplot as plt
File "/home/artivatic/.virtualenvs/test/lib/python3.5/site-packages/matplotlib/pyplot.py", line 32, in
import matplotlib.colorbar
File "/home/artivatic/.virtualenvs/test/lib/python3.5/site-packages/matplotlib/colorbar.py", line 28, in
import matplotlib.artist as martist
File "/home/artivatic/.virtualenvs/test/lib/python3.5/site-packages/matplotlib/artist.py", line 10, in
from . import cbook, docstring, rcParams
ImportError: cannot import name 'rcParams'

Any solution?

@WeatherGod
Copy link
Member

WeatherGod commented Dec 13, 2018 via email

@santhoshav15
Copy link

@WeatherGod I have pip3(only for python 3), no pip installed. Python version 3.5.2 standard that comes along with standard Ubuntu 16.04
I had even opened a thread ImportError: cannot import name 'rcParams'

The issue got fixed obviously after i changed the name of dis.py

@pluviosilla
Copy link

I'm getting the same error under very similar circumstances (importing matplotlib pyplot with a failure in the attempt to load colorbar, then martist, then rcParams), but I do not have dis.py or any other python (.py) files in my working directory. However, I think (but am not sure) that the problem started after I installed statsmodels. I'm running a jupyter notebook within a conda environment with python 3.6 and matplotlib-3.0.2-py36_1002.

@WeatherGod
Copy link
Member

WeatherGod commented Feb 1, 2019 via email

@pluviosilla
Copy link

Thanks for taking time to respond. Here's the traceback:

After the import
from matplotlib import pyplot as plt
I get

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-52-99ba79ecbbfb> in <module>
----> 1 from matplotlib import pyplot as plt

C:\Anaconda3\envs\py36-keras\lib\site-packages\matplotlib\pyplot.py in <module>
     30 from cycler import cycler
     31 import matplotlib
---> 32 import matplotlib.colorbar
     33 import matplotlib.image
     34 from matplotlib import rcsetup, style

C:\Anaconda3\envs\py36-keras\lib\site-packages\matplotlib\colorbar.py in <module>
     26 
     27 import matplotlib as mpl
---> 28 import matplotlib.artist as martist
     29 import matplotlib.cbook as cbook
     30 import matplotlib.collections as collections

C:\Anaconda3\envs\py36-keras\lib\site-packages\matplotlib\artist.py in <module>
      8 
      9 import matplotlib
---> 10 from . import cbook, docstring, rcParams
     11 from .path import Path
     12 from .transforms import (Bbox, IdentityTransform, Transform, TransformedBbox,

ImportError: cannot import name 'rcParams'

@WeatherGod
Copy link
Member

WeatherGod commented Feb 1, 2019 via email

@pluviosilla
Copy link

How can I verify that it is valid? You can view the file here.

@jklymak
Copy link
Member

jklymak commented Feb 1, 2019

@pluviosilla Can you do

import logging
logging.basicConfig(level=logging.DEBUG)
import matplotlib.pyplot as plt

Its just that your install is messed up somehow - running the debugging will help us see how.

@pluviosilla
Copy link

Nothing changes, unfortunately:

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-53-ebf44ebd011b> in <module>
      1 import logging
      2 logging.basicConfig(level=logging.DEBUG)
----> 3 import matplotlib.pyplot as plt

C:\Anaconda3\envs\py36-keras\lib\site-packages\matplotlib\pyplot.py in <module>
     30 from cycler import cycler
     31 import matplotlib
---> 32 import matplotlib.colorbar
     33 import matplotlib.image
     34 from matplotlib import rcsetup, style

C:\Anaconda3\envs\py36-keras\lib\site-packages\matplotlib\colorbar.py in <module>
     26 
     27 import matplotlib as mpl
---> 28 import matplotlib.artist as martist
     29 import matplotlib.cbook as cbook
     30 import matplotlib.collections as collections

C:\Anaconda3\envs\py36-keras\lib\site-packages\matplotlib\artist.py in <module>
      8 
      9 import matplotlib
---> 10 from . import cbook, docstring, rcParams
     11 from .path import Path
     12 from .transforms import (Bbox, IdentityTransform, Transform, TransformedBbox,

ImportError: cannot import name 'rcParams'

@pluviosilla
Copy link

And changing the debugging level has no effect on the amount of spew.

@jklymak
Copy link
Member

jklymak commented Feb 1, 2019

That means that you do not have a recent matplotlib installed in C:\Anaconda3\envs\py36-keras Try updating.

@pluviosilla
Copy link

These problems occur in a newly created conda environment where I installed matplotlib in the usual way:
conda install matplotlib -n py36-keras
After experiencing all these difficulties I tried uninstalling and reinstalling as well as:
conda install matplotlib -c conda-forge -n py36-keras

Versions: python 3.6 and matplotlib-3.0.2-py36_1002.

@jklymak
Copy link
Member

jklymak commented Feb 1, 2019

Does conda really install in C:\Anaconda3 on Windows? What does conda info give you?

You can also try:

import logging
logging.basicConfig(level=logging.DEBUG)
import matplotlib
print('Version', matplotlib.__version__)
import matplotlib.pyplot as plt

@pluviosilla
Copy link

Here's what I get:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-60-4ac91ebc2005> in <module>
      2 logging.basicConfig(level=logging.DEBUG)
      3 import matplotlib
----> 4 print('Version', matplotlib.__version__)
      5 import matplotlib.pyplot as plt

AttributeError: module 'matplotlib' has no attribute '__version__'

As for my conda installation info, here's what I get:

C:\WINDOWS\system32>conda info

     active environment : None
       user config file : C:\Users\John\.condarc
 populated config files : C:\Users\John\.condarc
          conda version : 4.6.2
    conda-build version : 3.4.1
         python version : 3.6.4.final.0
       base environment : C:\Anaconda3  (writable)
           channel URLs : https://conda.anaconda.org/conda-forge/win-64
                          https://conda.anaconda.org/conda-forge/noarch
                          https://repo.anaconda.com/pkgs/main/win-64
                          https://repo.anaconda.com/pkgs/main/noarch
                          https://repo.anaconda.com/pkgs/free/win-64
                          https://repo.anaconda.com/pkgs/free/noarch
                          https://repo.anaconda.com/pkgs/r/win-64
                          https://repo.anaconda.com/pkgs/r/noarch
                          https://repo.anaconda.com/pkgs/msys2/win-64
                          https://repo.anaconda.com/pkgs/msys2/noarch
          package cache : C:\Anaconda3\pkgs
                          C:\Users\John\.conda\pkgs
                          C:\Users\John\AppData\Local\conda\conda\pkgs
       envs directories : C:\Anaconda3\envs
                          C:\Users\John\.conda\envs
                          C:\Users\John\AppData\Local\conda\conda\envs
               platform : win-64
             user-agent : conda/4.6.2 requests/2.18.4 CPython/3.6.4 Windows/10 Windows/10.0.17134
          administrator : True
             netrc file : None
           offline mode : False

@jklymak
Copy link
Member

jklymak commented Feb 1, 2019

The fact you can't even print the __version__ means your install is broken.

I'd clean up your conda install - in particular, I don't think you want the C:\Anaconda3 path in there, but I'm not an expert on how conda works on Windows machines.

@pluviosilla
Copy link

I don't think the "Anaconda3" is the problem. Been using that for ages and never had this kind of problem before.

I have a number of conda environments. Maybe too many.

@WeatherGod
Copy link
Member

WeatherGod commented Feb 1, 2019 via email

@jklymak
Copy link
Member

jklymak commented Feb 2, 2019

@pluviosilla If you are still having trouble, probably worth opening a new issue. But please make sure its not a conda problem first, which this really seems to be. We can't really debug install issues.

@MorganWeiss
Copy link

I still have the same issue, is there any solution. I tried uninstalling and installing matplotlib but I still get the same error message: ImportError: cannot import name 'rcParams' from 'matplotlib' (unknown location)

@kvamsi7
Copy link

kvamsi7 commented Jun 13, 2021

I still have the same issue, is there any solution. I tried uninstalling and installing matplotlib but I still get the same error message: ImportError: cannot import name 'rcParams' from 'matplotlib' (unknown location)

Have you tried conda install -f matplotlib

@dentalfloss1
Copy link

I have this issue and I don't have anaconda at all

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants