• notice
  • Congratulations on the launch of the Sought Tech site

Error using submodule without import

This may not be the best MWE, but I'm not sure if this is a specific problem, or if I Just don't understand the basics.this works:

import matplotlib as mpl
import matplotlib.backends.backend_tkcairo as tkcairo
fig=mpl.figure.Figure()
canvas=tkcairo.FigureCanvasTkCairo(fig)

I think this should also work:

import matplotlib as mpl
fig=mpl.figure.Figure()
canvas=mpl.backends.backend_tkcairo.FigureCanvasTkCairo(fig)

but it doesn't (Module 'matplotlib' has no attribute 'figure').Why this doesn't work and why the errors related to mpl.figure.Figure() don't differ between the two MWEs?

uj5u.com enthusiastic netizens replied:

matplotlibsubmodules will not be imported automatically font>figureor submodule backends, but backends.backend_tkcairoImportfigure.

Just importing a module does not necessarily mean that all submodules will follow.It depends on how these are written.

In this case, it is better to explicitly import the submodules you need.

Tags

Technical otaku

Sought technology together

Related Topic

1 Comments

author

order lipitor 80mg without preion & lt;a href="https://lipiws.top/"& gt;lipitor 20mg for sale& lt;/a& gt; buy atorvastatin 10mg generic

Bwlzeu

2024-03-10

Leave a Reply

+