在Visual Studio Code中使用matplotlib显示图形时,图形没有响应,错误信息如下:无法为'qt'启用GUI事件循环集成Traceback(大多数记录)...
在Visual Studio Code中使用matplotlib显示图形时,图形无响应,错误信息如下:
Failed to enable GUI event loop integration for 'qt'
Traceback (most recent call last):
File "~\.vscode\extensions\ms-python.debugpy-2024.8.0-win32-x64\bundled\libs\debugpy\_vendored\pydevd\pydev_ipython\matplotlibtools.py", line 30, in do_enable_gui
enable_gui(guiname)
File "~\.vscode\extensions\ms-python.debugpy-2024.8.0-win32-x64\bundled\libs\debugpy\_vendored\pydevd\pydev_ipython\inputhook.py", line 540, in enable_gui
return gui_hook(app)
^^^^^^^^^^^^^
File "~\.vscode\extensions\ms-python.debugpy-2024.8.0-win32-x64\bundled\libs\debugpy\_vendored\pydevd\pydev_ipython\inputhook.py", line 176, in enable_qt
from pydev_ipython.qt_for_kernel import QT_API, QT_API_PYQT5
File "~\.vscode\extensions\ms-python.debugpy-2024.8.0-win32-x64\bundled\libs\debugpy\_vendored\pydevd\pydev_ipython\qt_for_kernel.py", line 116, in <module>
QtCore, QtGui, QtSvg, QT_API = load_qt(api_opts)
^^^^^^^^^^^^^^^^^
File "~\.vscode\extensions\ms-python.debugpy-2024.8.0-win32-x64\bundled\libs\debugpy\_vendored\pydevd\pydev_ipython\qt_loaders.py", line 276, in load_qt
if not can_import(api):
^^^^^^^^^^^^^^^
File "~\.vscode\extensions\ms-python.debugpy-2024.8.0-win32-x64\bundled\libs\debugpy\_vendored\pydevd\pydev_ipython\qt_loaders.py", line 152, in can_import
if not has_binding(api):
^^^^^^^^^^^^^^^^
File "~\.vscode\extensions\ms-python.debugpy-2024.8.0-win32-x64\bundled\libs\debugpy\_vendored\pydevd\pydev_ipython\qt_loaders.py", line 115, in has_binding
import imp
ModuleNotFoundError: No module named 'imp'
Backend QtAgg is interactive backend. Turning interactive mode on.
我的代码如下(原代码经过了处理,能触发这个Bug的代码如下):
import torch
import matplotlib.pyplot as plt
def main():
data = torch.arange(1, 10)
plt.plot(data)
plt.title('label name')
# ……
if __name__ == '__main__':
main()
使用的时候 plt.ion()
不起作用。
我在装有 Ubuntu 操作系统的机器上安装了 Docker。当我运行:sudo docker run hello-worldAll 时没问题,但我想隐藏 sudo 命令以使命令更短。如果我写命令
我在装有 Ubuntu 操作系统的机器上安装了 Docker。
当我跑步时:
sudo docker run hello-world
一切正常,但我想隐藏命令 sudo
以使命令更短。
如果我写命令时不带 sudo
docker run hello-world
显示以下内容:
docker: Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Post http://%2Fvar%2Frun%2Fdocker.sock/v1.35/containers/create: dial unix /var/run/docker.sock: connect: permission denied. See 'docker run --help'.
当我尝试运行时也会发生同样的事情:
docker-compose up
我该如何解决这个问题?