Bug report #11268

Error when importing matplotlib 1.4

Added by Tobias Schneider about 6 years ago. Updated about 6 years ago.

Status:Rejected
Priority:Normal
Assignee:-
Category:-
Affected QGIS version:master Regression?:No
Operating System: Easy fix?:No
Pull Request or Patch supplied:No Resolution:invalid
Crashes QGIS or corrupts data:No Copied to github as #:19567

Description

In the current 2.5.0-Master I can't seem to import Matplotlib, which has recently been updated to 1.4.

When typing "import matplotlib.pyplot as plt" in the Python console I get:

>>>import matplotlib.pyplot as plt
Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "/usr/lib/python2.7/dist-packages/qgis/utils.py", line 454, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
  File "/usr/lib/pymodules/python2.7/matplotlib/pyplot.py", line 28, in <module>
    from matplotlib import style
  File "/usr/lib/python2.7/dist-packages/qgis/utils.py", line 454, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
  File "/usr/lib/pymodules/python2.7/matplotlib/style/__init__.py", line 3, in <module>
    from .core import use, context, available, library, reload_library
  File "/usr/lib/python2.7/dist-packages/qgis/utils.py", line 454, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
  File "/usr/lib/pymodules/python2.7/matplotlib/style/core.py", line 149, in <module>
    _base_library = load_base_library()
  File "/usr/lib/pymodules/python2.7/matplotlib/style/core.py", line 94, in load_base_library
    library.update(read_style_directory(BASE_LIBRARY_PATH))
  File "/usr/lib/pymodules/python2.7/matplotlib/style/core.py", line 126, in read_style_directory
    for path, name in iter_style_files(style_dir):
  File "/usr/lib/pymodules/python2.7/matplotlib/style/core.py", line 115, in iter_style_files
    for path in os.listdir(style_dir):
OSError: [Errno 2] Datei oder Verzeichnis nicht gefunden: '/usr/share/matplotlib/mpl-data/stylelib'

Is this related to QGIS or to the new Matplotlib?

History

#1 Updated by Regis Haubourg about 6 years ago

Hi, same here in osgeo4w

#2 Updated by Tobias Schneider about 6 years ago

Hi Regis! Do you also have Matplotlib 1.4 or 1.3? I use Ubuntu 14.04 64 bit and you?

#3 Updated by Alexander Bruy about 6 years ago

  • Resolution set to invalid
  • Status changed from Open to Rejected

Seems this is not QGIS issue, but matplotlib one.

#4 Updated by Tobias Schneider about 6 years ago

@Alexander: It most likely is a Matplotlib problem, but I wonder how many plugins this will affect.

I get the same output from the regular Python console:

>>> import matplotlib.pyplot as plt
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/pymodules/python2.7/matplotlib/pyplot.py", line 28, in <module>
    from matplotlib import style
  File "/usr/lib/pymodules/python2.7/matplotlib/style/__init__.py", line 3, in <module>
    from .core import use, context, available, library, reload_library
  File "/usr/lib/pymodules/python2.7/matplotlib/style/core.py", line 149, in <module>
    _base_library = load_base_library()
  File "/usr/lib/pymodules/python2.7/matplotlib/style/core.py", line 94, in load_base_library
    library.update(read_style_directory(BASE_LIBRARY_PATH))
  File "/usr/lib/pymodules/python2.7/matplotlib/style/core.py", line 126, in read_style_directory
    for path, name in iter_style_files(style_dir):
  File "/usr/lib/pymodules/python2.7/matplotlib/style/core.py", line 115, in iter_style_files
    for path in os.listdir(style_dir):
OSError: [Errno 2] No such file or directory: '/usr/share/matplotlib/mpl-data/stylelib'

and Python 3:

>>> import matplotlib.pyplot as plt
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3/dist-packages/matplotlib/pyplot.py", line 28, in <module>
    from matplotlib import style
  File "/usr/lib/python3/dist-packages/matplotlib/style/__init__.py", line 3, in <module>
    from .core import use, context, available, library, reload_library
  File "/usr/lib/python3/dist-packages/matplotlib/style/core.py", line 149, in <module>
    _base_library = load_base_library()
  File "/usr/lib/python3/dist-packages/matplotlib/style/core.py", line 94, in load_base_library
    library.update(read_style_directory(BASE_LIBRARY_PATH))
  File "/usr/lib/python3/dist-packages/matplotlib/style/core.py", line 126, in read_style_directory
    for path, name in iter_style_files(style_dir):
  File "/usr/lib/python3/dist-packages/matplotlib/style/core.py", line 115, in iter_style_files
    for path in os.listdir(style_dir):
FileNotFoundError: [Errno 2] No such file or directory: '/usr/share/matplotlib/mpl-data/stylelib'

#5 Updated by Tobias Schneider about 6 years ago

Tracking the bug now at Matplotlib:

https://github.com/matplotlib/matplotlib/issues/3568

Also available in: Atom PDF