from IPython import get_ipython

get_ipython().run_line_magic('matplotlib', 'inline')

替代