在终端中打开 Jupyter-Notebook 即可打开 Telegram 桌面!

在终端中打开 Jupyter-Notebook 即可打开 Telegram 桌面!

我在使用 Ubuntu 20.04.2 LTS。

当我想在终端中打开 Jupyter-Notebook 时,电报桌面应用程序就会打开。

Jupyter-Notebook 实际上是在后台打开的。所以我可以打开浏览器并使用它。

输出如下:

(geospatial) siavash@siavash-fra:~$ jupyter-notebook 
[I 16:59:52.522 NotebookApp] Serving notebooks from local directory: /home/siavash
[I 16:59:52.522 NotebookApp] The Jupyter Notebook is running at:
[I 16:59:52.522 NotebookApp] http://localhost:8888/?token=192817dbf13703bc25bbd1f348df5e9c1c7c9275d579aef3
[I 16:59:52.522 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 16:59:52.526 NotebookApp] 
    
    To access the notebook, open this file in a browser:
        file:///home/siavash/.local/share/jupyter/runtime/nbserver-5326-open.html
    Or copy and paste one of these URLs:
        http://localhost:8888/?token=192817dbf13703bc25bbd1f348df5e9c1c7c9275d579aef3

(telegram-desktop:5339): lib_base-WARNING **: 16:59:53.204: Unfortunately, GTK integration conflicts with qgtk2 platformtheme and style. Therefore, QT_QPA_PLATFORMTHEME and QT_STYLE_OVERRIDE will be unset.
lib_base-Message: 16:59:53.204: This can be ignored by setting DESKTOP_APP_I_KNOW_ABOUT_GTK_INCOMPATIBILITY environment variable to any value, however, if qgtk2 theme or style is used, this will lead to a crash.
lib_base-Message: 16:59:53.204: GTK integration can be disabled by setting DESKTOP_APP_DISABLE_GTK_INTEGRATION to any value. Keep in mind that this will lead to some features being unavailable.
Gtk-Message: 16:59:53.412: Failed to load module "canberra-gtk-module"
Gtk-Message: 16:59:53.413: Failed to load module "canberra-gtk-module"
[ALSOFT] (EE) Failed to set real-time priority for thread: Operation not permitted (1)

我也看了类似的问题,但它没有回答我的问题。

答案1

我发现了问题:安装 telegram 后,奇怪的是它使 telegram 成为打开 HTML 文件的默认应用程序。这就是为什么jupyter-notebook在终端中运行后,它会尝试使用 telegram 打开链接。

因此,要解决这个问题,只需找到任何 HTML 文件。右键单击它。转到Properties。在Open With选项卡中选择您的浏览器,然后单击Set as default

问题已解决。下次电报将无法打开。相反,您将在浏览器上运行 jupyter-notebook。

答案2

值得注意的是,你应该通过不同的端口

我无法重现此错误,也无法找到强制 telegram-desktop 使用其他端口的方法,但您可以将 jupyter notebook 配置为使用除 之外的端口8888

首先,检查文件是否/home/USERNAME/.jupyter/jupyter_notebook_config.py存在。如果不存在,则运行jupyter notebook --generate-config

然后,打开此文件并取消注释以下行,将端口更改为8889,例如:

c.NotebookApp.port = 8888
                      ^ Change this port to 8889

保存文件并再次运行 jupyter notebook。从现在起,电报桌面应该不会打开。

相关内容