Title: [Bug]: Import Error in Matplotlib 3.5.1 · Issue #22305 · matplotlib/matplotlib · GitHub
Open Graph Title: [Bug]: Import Error in Matplotlib 3.5.1 · Issue #22305 · matplotlib/matplotlib
X Title: [Bug]: Import Error in Matplotlib 3.5.1 · Issue #22305 · matplotlib/matplotlib
Description: Bug summary Cannot create a matplotlib.ticker.ScalarFormatter() without importing "unnecessary" imports. Code for reproduction import matplotlib print(matplotlib.__version__) import matplotlib.ticker matplotlib.ticker.ScalarFormatter() #...
Open Graph Description: Bug summary Cannot create a matplotlib.ticker.ScalarFormatter() without importing "unnecessary" imports. Code for reproduction import matplotlib print(matplotlib.__version__) import matplotlib.tick...
X Description: Bug summary Cannot create a matplotlib.ticker.ScalarFormatter() without importing "unnecessary" imports. Code for reproduction import matplotlib print(matplotlib.__version__) import matpl...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/22305
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Bug]: Import Error in Matplotlib 3.5.1","articleBody":"### Bug summary\n\nCannot create a `matplotlib.ticker.ScalarFormatter()` without importing \"unnecessary\" imports.\n\n### Code for reproduction\n\n```python\nimport matplotlib\r\nprint(matplotlib.__version__)\r\nimport matplotlib.ticker\r\nmatplotlib.ticker.ScalarFormatter()\r\n```\n```\n\n\n### Actual outcome\n\n```---------------------------------------------------------------------------\r\nAttributeError Traceback (most recent call last)\r\nInput In [1], in \u003cmodule\u003e\r\n 2 print(matplotlib.__version__)\r\n 3 import matplotlib.ticker\r\n----\u003e 4 matplotlib.ticker.ScalarFormatter()\r\n\r\nFile /usr/lib/python3.10/site-packages/matplotlib/ticker.py:444, in ScalarFormatter.__init__(self, useOffset, useMathText, useLocale)\r\n 442 if useMathText is False:\r\n 443 try:\r\n--\u003e 444 ufont = mpl.font_manager.findfont(\r\n 445 mpl.font_manager.FontProperties(\r\n 446 mpl.rcParams[\"font.family\"]\r\n 447 ),\r\n 448 fallback_to_default=False,\r\n 449 )\r\n 450 except ValueError:\r\n 451 ufont = None\r\n\r\nFile /usr/lib/python3.10/site-packages/matplotlib/_api/__init__.py:222, in caching_module_getattr.\u003clocals\u003e.__getattr__(name)\r\n 220 if name in props:\r\n 221 return props[name].__get__(instance)\r\n--\u003e 222 raise AttributeError(\r\n 223 f\"module {cls.__module__!r} has no attribute {name!r}\")\r\n\r\nAttributeError: module 'matplotlib' has no attribute 'font_manager'\r\n```\n\n### Expected outcome\n\nshould run without error **as in previous versions.**\n\n### Additional information\n\nAs a workaround just execute the following command before creating the ScalarFormatter\r\n```\r\nimport matplotlib.font_manager\r\n```\n\n### Operating system\n\nArch Linux\n\n### Matplotlib Version\n\n3.5.1\n\n### Matplotlib Backend\n\nmodule://matplotlib_inline.backend_inline\n\n### Python version\n\n3.10.2\n\n### Jupyter version\n\n3.2.8 (dev), 3.0.16 (app)\n\n### Installation\n\nLinux package manager","author":{"url":"https://github.com/skuschel","@type":"Person","name":"skuschel"},"datePublished":"2022-01-24T18:07:27.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/22305/matplotlib/issues/22305"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:5d5ad359-6a44-2a02-31ac-70c6566a53e2 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | ECAA:243073:507194:6C9E43:6A5296AB |
| html-safe-nonce | 814400edfe2963a1bfe38a62c6de7f3143433d541c20fc1ad07db1d1699fd809 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFQ0FBOjI0MzA3Mzo1MDcxOTQ6NkM5RTQzOjZBNTI5NkFCIiwidmlzaXRvcl9pZCI6IjEwOTQ5NzM1OTcxNzk2MTQ4OTEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 14d894b292f3fa3e1eb29ce7e44fa808f555d1fd2352a443db00ac95affd3f4d |
| hovercard-subject-tag | issue:1112975444 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/matplotlib/matplotlib/22305/issue_layout |
| twitter:image | https://opengraph.githubassets.com/46030e3727cbbe44e4c06a6e0d844f6f86d030d681e28b7d453122cec8f0b6d6/matplotlib/matplotlib/issues/22305 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/46030e3727cbbe44e4c06a6e0d844f6f86d030d681e28b7d453122cec8f0b6d6/matplotlib/matplotlib/issues/22305 |
| og:image:alt | Bug summary Cannot create a matplotlib.ticker.ScalarFormatter() without importing "unnecessary" imports. Code for reproduction import matplotlib print(matplotlib.__version__) import matplotlib.tick... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | skuschel |
| hostname | github.com |
| expected-hostname | github.com |
| None | b9a586c06a05a7a86fc7e3f4dbd03e42f6869085879aa184aa6369456dbd50fb |
| turbo-cache-control | no-preview |
| go-import | github.com/matplotlib/matplotlib git https://github.com/matplotlib/matplotlib.git |
| octolytics-dimension-user_id | 215947 |
| octolytics-dimension-user_login | matplotlib |
| octolytics-dimension-repository_id | 1385122 |
| octolytics-dimension-repository_nwo | matplotlib/matplotlib |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1385122 |
| octolytics-dimension-repository_network_root_nwo | matplotlib/matplotlib |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 07a982c1d40157c619b364352b704c3ce66bb332 |
| ui-target | canary-2 |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width