在Windows 11中从ubuntu bash调用spyder导致错误

发布于 2025-01-11 07:09:05 字数 1122 浏览 0 评论 0原文

我使用的是Win 11,

我安装了wsl2和ubuntu bash,

我还安装了spyder,但每次我尝试运行它时,我都会收到错误,

asmgx@DELLG3:~$ spyder
/home/asmgx/.local/lib/python3.8/site-packages/pkg_resources/__init__.py:122: PkgResourcesDeprecationWarning: 0.23ubuntu1 is an invalid version and will not be supported in a future release
  warnings.warn(
/home/asmgx/.local/lib/python3.8/site-packages/pkg_resources/__init__.py:122: PkgResourcesDeprecationWarning: 0.1.36ubuntu1 is an invalid version and will not be supported in a future release
  warnings.warn(
qt.qpa.xcb: could not connect to display :0.0
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, xcb.

Aborted

我用谷歌搜索并尝试了不同的解决方案,

例如

pip install spyder

pip install --upgrade spyder

pip install PyQt5

export QT_DEBUG_PLUGINS=1

但没有工作,

有人知道我怎样才能让spyder运行吗?

I am using Win 11

I installed wsl2 and ubuntu bash

i also installed spyder but everytime i try to run it i get error

asmgx@DELLG3:~$ spyder
/home/asmgx/.local/lib/python3.8/site-packages/pkg_resources/__init__.py:122: PkgResourcesDeprecationWarning: 0.23ubuntu1 is an invalid version and will not be supported in a future release
  warnings.warn(
/home/asmgx/.local/lib/python3.8/site-packages/pkg_resources/__init__.py:122: PkgResourcesDeprecationWarning: 0.1.36ubuntu1 is an invalid version and will not be supported in a future release
  warnings.warn(
qt.qpa.xcb: could not connect to display :0.0
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, xcb.

Aborted

I googled and tried different solutioins proposed

such as

pip install spyder

pip install --upgrade spyder

pip install PyQt5

export QT_DEBUG_PLUGINS=1

but non worked

any one know how can i get spyder running?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

鯉魚旗 2025-01-18 07:09:05

pyder 文档常见问题 解释如何连接。

如果您已在 Windows 计算机上安装了 Spyder,并且您的代码必须在基于 WSL2 的 Linux 环境中运行,则无需在该环境中重新安装它。
相反,只需在 WSL2 中安装 Miniconda 并创建一个新的 conda 环境(或使用现有的 conda- 或 virtualenv),然后安装 Spyder-Kernels使用例如 conda install spyder-kernels 进入该环境。您必须使用例如 conda install ipython_genutils

手动安装 ipython_genutils

要启动 Spyder 内核,请从 Linux 终端运行

python -m spyder_kernels.console --matplotlib="inline" --ip=127.0.0.1 -f=~/remotemachine.json &

它将作为子进程运行内核,并在 WSL 主文件夹中创建一个名为remotemachine.json 的文件。

最后,在 Spyder 的 IPython 控制台的选项菜单下,选择连接到现有内核,如使用外部内核中所述。将remotemachine.json 的绝对路径插入到连接文件字段中。如果您按照上面的注释映射了 W:,则路径应为 W:/home/username/remotemachine.json。 Spyder 将打开一个新控制台,在 Linux 环境中运行。尝试运行 os.system('ls -la') 并查看它是否列出了您的 WSL 主文件夹。如果您从 Spyder 运行 exit(),Linux 上运行的内核将停止。

您可以使用此网址进行任何更新。

在我看来,它的工作很完美。

spyder document Frequently Asked Questionsits explain how to connect.

If you already installed Spyder on your Windows machine, you do not need to reinstall it on a WSL2-based Linux environment if your code must run there.
Instead, just install Miniconda inside WSL2 and create a new conda environment (or use an existing conda- or virtualenv), then install Spyder-Kernels into that environment with e.g. conda install spyder-kernels. You must manually install ipython_genutils with e.g. conda install ipython_genutils

To start a Spyder kernel, from your Linux terminal run

python -m spyder_kernels.console --matplotlib="inline" --ip=127.0.0.1 -f=~/remotemachine.json &

It will run the kernel as a subprocess and create a file named remotemachine.json in your WSL home folder.

Finally, under the options menu of Spyder’s IPython Console, select Connect to an existing kernel as described in Using external kernels. Insert the absolute path of remotemachine.json into the Connection file field. If you mapped W: as mentioned in above note, the path should be W:/home/username/remotemachine.json. A new console will open in Spyder, running in the Linux environment. Try running os.system('ls -la') and see if it lists your WSL home folder. If you run exit() from Spyder, the kernel running on Linux will be stopped.

You can fallow this url for any update.

At my end its work perfactly.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文