Thanks to visit codestin.com
Credit goes to github.com

Skip to content

installing matplotlib changes behavior of importlib #19612

Description

@odoublewen

Bug report

After installing matplotlib, import importlib causes importlib.machinery to be available.

Before installing matplotlib (or after uninstalling it), import importlib.machinery is necessary to access the machinery module.

This may seem benign (after all, I'm not saying matplotlib breaks importlib) but I lost a chunk of time tracing down the source of the inconsistency. I can't see any reason why this package should change importlib's behavior.

Code for reproduction

Expected behavior

$ python -c 'import importlib; print(importlib.machinery)'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
AttributeError: module 'importlib' has no attribute 'machinery'

Actual behavior

$ pip install matplotlib
Looking in indexes: https://pypi.org/simple
Collecting matplotlib
  Using cached matplotlib-3.3.4-cp38-cp38-manylinux1_x86_64.whl (11.6 MB)
...
Successfully installed matplotlib-3.3.4

$ python -c 'import importlib; print(importlib.machinery)'
<module 'importlib.machinery' from '/opt/python/Python-3.8.1/Lib/importlib/machinery.py'>

Matplotlib version

  • Operating system: confirmed on linux (ubuntu 14.04, 18.04) and macos 10.15
  • Matplotlib version: 3.3.4
  • Python version: 3.8.6

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions