with demandimport.enabled():
# Doesn't work at all
import matplotlib.pyplot as plt
from matplotlib import pyplot as plt
from matplotlib import pyplot
# Works but can't be reassigned to `plt`.
import matplotlib.pyplot
plt = matplotlib.pyplot # Throws a huge error
plt = object.__getattribute__(matplotlib, "pyplot") # '_demandmod' object has no attribute 'pyplot'
The only form that actually worked was:
with demandimport.enabled():
import matplotlib.pyplot
plt = matplotlib.pyplot
type(plt) # demandimport._demandmod
I tried all of the following forms:
The only form that actually worked was: