Bug report #10849

Not importing directory '/usr/lib/python2.7/site-packages/mpl_toolkits'

Added by Donovan Cameron over 10 years ago. Updated over 10 years ago.

Status:Closed
Priority:Normal
Assignee:-
Category:Python plugins
Affected QGIS version:2.4.0 Regression?:No
Operating System: Easy fix?:No
Pull Request or Patch supplied:No Resolution:
Crashes QGIS or corrupts data:No Copied to github as #:19221

Description

I'm seeing a python warning in the Log Messages panel when starting QGIS for Linux, but it starts fine so not sure what's affected by it:

@warning:/usr/lib/python2.7/pkgutil.py:186: ImportWarning: Not importing directory '/usr/lib/python2.7/site-packages/mpl_toolkits': missing init.py
file, filename, etc = imp.find_module(subname, path)

traceback: File "<string>", line 1, in <module>
File "/usr/share/qgis/python/qgis/utils.py", line 204, in startPlugin
plugins[packageName] = package.classFactory(iface)
File "/usr/share/qgis/python/plugins/MetaSearch/__init__.py", line 32, in classFactory
from MetaSearch.plugin import MetaSearchPlugin
File "/usr/share/qgis/python/qgis/utils.py", line 454, in import
mod = _builtin_import(name, globals, locals, fromlist, level)
File "/usr/share/qgis/python/plugins/MetaSearch/plugin.py", line 33, in <module>
from MetaSearch.dialogs.maindialog import MetaSearchDialog
File "/usr/share/qgis/python/qgis/utils.py", line 454, in _import
mod = _builtin_import(name, globals, locals, fromlist, level)
File "/usr/share/qgis/python/plugins/MetaSearch/dialogs/maindialog.py", line 45, in <module>
from owslib.csw import CatalogueServiceWeb
File "/usr/share/qgis/python/qgis/utils.py", line 454, in _import
mod = _builtin_import(name, globals, locals, fromlist, level)
File "/usr/share/qgis/python/owslib/csw.py", line 18, in <module>
from owslib import fes
File "/usr/share/qgis/python/qgis/utils.py", line 454, in _import
mod = _builtin_import(name, globals, locals, fromlist, level)
File "/usr/share/qgis/python/owslib/fes.py", line 19, in <module>
from owslib import util
File "/usr/share/qgis/python/qgis/utils.py", line 454, in _import
mod = _builtin_import(name, globals, locals, fromlist, level)
File "/usr/share/qgis/python/owslib/util.py", line 13, in <module>
import pytz
File "/usr/share/qgis/python/qgis/utils.py", line 454, in _import
mod = _builtin_import(name, globals, locals, fromlist, level)
File "/usr/share/qgis/python/pytz/
_init__.py", line 29, in <module>
from pkg_resources import resource_stream
File "/usr/share/qgis/python/qgis/utils.py", line 454, in _import
mod = _builtin_import(name, globals, locals, fromlist, level)
File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 2888, in <module>
add_activation_listener(lambda dist: dist.activate())
File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 758, in subscribe
callback(dist)
File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 2888, in <lambda>
add_activation_listener(lambda dist: dist.activate())
File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 2427, in activate
declare_namespace(pkg)
File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 2009, in declare_namespace
_handle_ns(packageName, path_item)
File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 1961, in _handle_ns
loader = importer.find_module(packageName)@

I've got python2-matplotlib 1.3.1 installed.

But that directory exists and there isn't an __init__.py file,
% ls /usr/lib/python2.7/site-packages/mpl_toolkits/
axes_grid axes_grid1 axisartist exceltools.py exceltools.pyc exceltools.pyo gtktools.py gtktools.pyc gtktools.pyo mplot3d

I did find __init__.py in the following places,
% find /usr/lib/python2.7/site-packages/mpl_toolkits -type f -name '*init*.py'
/usr/lib/python2.7/site-packages/mpl_toolkits/axisartist/__init__.py
/usr/lib/python2.7/site-packages/mpl_toolkits/mplot3d/__init__.py
/usr/lib/python2.7/site-packages/mpl_toolkits/axes_grid/__init__.py
/usr/lib/python2.7/site-packages/mpl_toolkits/axes_grid1/__init__.py

History

#1 Updated by Donovan Cameron over 10 years ago

I was able to fix by copying the needed file from:

https://github.com/matplotlib/matplotlib/blob/v1.3.x/lib/mpl_toolkits/__init__.py

try:
__import__('pkg_resources').declare_namespace(__name__)
except ImportError:
pass # must not have setuptools

So I'm wondering if this is a packaging issue for Arch Linux (some other distros are reporting it as well). I'll inquire with the package maintainer.

#2 Updated by Donovan Cameron over 10 years ago

  • Status changed from Open to Closed

Yup, looks like it's an upstream issue (fixed in matplotlib master for now). Closed for invalid =)

Also available in: Atom PDF