Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Why is mpl_toolkits loaded?
#1
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 Bonkself
Reply
#2
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_toolkits
Also see what happens with
python -S # Don't load the "site" module
>>> import sys
>>> sys.modules
It 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.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Thumbs Up mpl_toolkits rf_kartal 0 315 Sep-21-2021, 12:10 PM
Last Post: rf_kartal
  Package cannot be loaded into PBS queue file emersonpl 1 358 Sep-09-2021, 08:06 PM
Last Post: emersonpl
  PyQt5 MySQL Drivers Not Loaded AdeS 7 958 Aug-06-2021, 08:34 AM
Last Post: AdeS
  MacOS BigSur Python3 - dyld: Library not loaded: trillionanswers 1 2,525 Mar-02-2021, 11:00 PM
Last Post: nilamo
  start interactive pyhton shell with pre-loaded custom modules Viktor 2 961 Apr-09-2020, 08:25 AM
Last Post: Viktor
  external refs by libraries loaded with cdll caldodge 0 766 Jul-01-2019, 10:26 PM
Last Post: caldodge
  When are imports loaded? MuntyScruntfundle 2 1,344 Feb-10-2019, 03:47 PM
Last Post: ichabod801

Forum Jump:

User Panel Messages

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