Why is mpl_toolkits loaded? - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Why is mpl_toolkits loaded? (/thread-32239.html) |
Why is mpl_toolkits loaded? - Gribouillis - Jan-29-2021 There is a strange behavior of Python on my machine: ~/P/S/2021-01 python3.8 Python 3.8.7 (default, Dec 21 2020, 21:23:03) [GCC 5.4.0 20160609] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import sys >>> sys.modules['mpl_toolkits'] <module 'mpl_toolkits' (namespace)> >>> import pkg_resources >>> sys.modules['mpl_toolkits'] <module 'mpl_toolkits' from '/usr/lib/python3/dist-packages/mpl_toolkits/__init__.py'>When I start Python 3.8, there is already an 'mpl_toolkits' entry in sys.modules , but this module is related to matplotlib, so how comes it appears in sys.modules without any attempt to use matplotlib?Worse, if I import pkg_resources , which is not related to matplotlib, this time the mpl_toolkits module is loaded from the dist-packages directory.Can someone give me a clue about this? I'm puzzled RE: Why is mpl_toolkits loaded? - Serafim - Jan-30-2021 I think that you just have a reference to it. It is not imported. Find out how with python -v(beware of massive output). You will probably find a line like # possible namespace for /<some path...>/site-packages/mpl_toolkitsAlso see what happens with python -S # Don't load the "site" module >>> import sys >>> sys.modulesIt should not appear in the output. If it does I'll be very puzzled. Not loading the site module means, among other things, that the site-packages directories aren't added to the module path at initialization. |