日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

成功解决import matplotlib; matplotlib.use('Agg') # pylint: disable=multiple-statements

發布時間:2025/3/21 编程问答 30 豆豆
生活随笔 收集整理的這篇文章主要介紹了 成功解决import matplotlib; matplotlib.use('Agg') # pylint: disable=multiple-statements 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

成功解決import matplotlib; matplotlib.use('Agg') ?# pylint: disable=multiple-statements

?

目錄

解決問題

解決思路

解決方法


?

解決問題

import matplotlib; matplotlib.use('Agg') # pylint: disable=multiple-statements The backend was *originally* set to 'module://ipykernel.pylab.backend_inline' by the following code:File "f:\program files\python\python36\lib\runpy.py", line 193, in _run_module_as_main"__main__", mod_spec)File "f:\program files\python\python36\lib\runpy.py", line 85, in _run_codeexec(code, run_globals)File "F:\Program Files\Python\Python36\Lib\site-packages\ipykernel_launcher.py", line 16, in <module>app.launch_new_instance()File "F:\Program Files\Python\Python36\Lib\site-packages\traitlets\config\application.py", line 658, in launch_instanceapp.start()File "F:\Program Files\Python\Python36\Lib\site-packages\ipykernel\kernelapp.py", line 486, in startself.io_loop.start()File "F:\Program Files\Python\Python36\Lib\site-packages\tornado\platform\asyncio.py", line 127, in startself.asyncio_loop.run_forever()File "f:\program files\python\python36\lib\asyncio\base_events.py", line 421, in run_foreverself._run_once()File "f:\program files\python\python36\lib\asyncio\base_events.py", line 1431, in _run_oncehandle._run()File "f:\program files\python\python36\lib\asyncio\events.py", line 145, in _runself._callback(*self._args)File "F:\Program Files\Python\Python36\Lib\site-packages\tornado\platform\asyncio.py", line 117, in _handle_eventshandler_func(fileobj, events)File "F:\Program Files\Python\Python36\Lib\site-packages\tornado\stack_context.py", line 276, in null_wrapperreturn fn(*args, **kwargs)File "F:\Program Files\Python\Python36\Lib\site-packages\zmq\eventloop\zmqstream.py", line 450, in _handle_eventsself._handle_recv()File "F:\Program Files\Python\Python36\Lib\site-packages\zmq\eventloop\zmqstream.py", line 480, in _handle_recvself._run_callback(callback, msg)File "F:\Program Files\Python\Python36\Lib\site-packages\zmq\eventloop\zmqstream.py", line 432, in _run_callbackcallback(*args, **kwargs)File "F:\Program Files\Python\Python36\Lib\site-packages\tornado\stack_context.py", line 276, in null_wrapperreturn fn(*args, **kwargs)File "F:\Program Files\Python\Python36\Lib\site-packages\ipykernel\kernelbase.py", line 283, in dispatcherreturn self.dispatch_shell(stream, msg)File "F:\Program Files\Python\Python36\Lib\site-packages\ipykernel\kernelbase.py", line 233, in dispatch_shellhandler(stream, idents, msg)File "F:\Program Files\Python\Python36\Lib\site-packages\ipykernel\kernelbase.py", line 399, in execute_requestuser_expressions, allow_stdin)File "F:\Program Files\Python\Python36\Lib\site-packages\ipykernel\ipkernel.py", line 208, in do_executeres = shell.run_cell(code, store_history=store_history, silent=silent)File "F:\Program Files\Python\Python36\Lib\site-packages\ipykernel\zmqshell.py", line 537, in run_cellreturn super(ZMQInteractiveShell, self).run_cell(*args, **kwargs)File "F:\Program Files\Python\Python36\Lib\site-packages\IPython\core\interactiveshell.py", line 2662, in run_cellraw_cell, store_history, silent, shell_futures)File "F:\Program Files\Python\Python36\Lib\site-packages\IPython\core\interactiveshell.py", line 2785, in _run_cellinteractivity=interactivity, compiler=compiler, result=result)File "F:\Program Files\Python\Python36\Lib\site-packages\IPython\core\interactiveshell.py", line 2909, in run_ast_nodesif self.run_code(code, result):File "F:\Program Files\Python\Python36\Lib\site-packages\IPython\core\interactiveshell.py", line 2963, in run_codeexec(code_obj, self.user_global_ns, self.user_ns)File "<ipython-input-2-0f0a85121700>", line 2, in <module>get_ipython().run_line_magic('matplotlib', 'inline')File "F:\Program Files\Python\Python36\Lib\site-packages\IPython\core\interactiveshell.py", line 2131, in run_line_magicresult = fn(*args,**kwargs)File "<decorator-gen-108>", line 2, in matplotlibFile "F:\Program Files\Python\Python36\Lib\site-packages\IPython\core\magic.py", line 187, in <lambda>call = lambda f, *a, **k: f(*a, **k)File "F:\Program Files\Python\Python36\Lib\site-packages\IPython\core\magics\pylab.py", line 99, in matplotlibgui, backend = self.shell.enable_matplotlib(args.gui)File "F:\Program Files\Python\Python36\Lib\site-packages\IPython\core\interactiveshell.py", line 3051, in enable_matplotlibpt.activate_matplotlib(backend)File "F:\Program Files\Python\Python36\Lib\site-packages\IPython\core\pylabtools.py", line 311, in activate_matplotlibmatplotlib.pyplot.switch_backend(backend)File "F:\Program Files\Python\Python36\Lib\site-packages\matplotlib\pyplot.py", line 231, in switch_backendmatplotlib.use(newbackend, warn=False, force=True)File "F:\Program Files\Python\Python36\Lib\site-packages\matplotlib\__init__.py", line 1410, in usereload(sys.modules['matplotlib.backends'])File "f:\program files\python\python36\lib\importlib\__init__.py", line 166, in reload_bootstrap._exec(spec, module)File "F:\Program Files\Python\Python36\Lib\site-packages\matplotlib\backends\__init__.py", line 16, in <module>line for line in traceback.format_stack()import matplotlib; matplotlib.use('Agg') # pylint: disable=multiple-statements

?

?

解決思路

原因之一,在最新的一個matplotlib版本中,此導入的方式不對。
有網友說還可能存在其他原因,如有其他解決辦法,歡迎網友留言!

?

?

?

解決方法

嘗試,將

from matplotlib import pyplot as plt ?

改為

import matplotlib.pyplot as plt

?

?

?

?

?

?

總結

以上是生活随笔為你收集整理的成功解决import matplotlib; matplotlib.use('Agg') # pylint: disable=multiple-statements的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。