在終端機中開啟 Jupyter-Notebook 將開啟 Telegram Desktop!

在終端機中開啟 Jupyter-Notebook 將開啟 Telegram Desktop!

我使用的是 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在終端機中運行後,它嘗試打開與電報的連結。

因此,要解決這個問題,只需找到任何 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。從現在開始,telegram 桌面將無法開啟。

相關內容