[英]Difficulty running jupyter notebook on Python2
我的計算機上同時安裝了 Python 2 ( 2.7.14
) 和 Python 3 ( 3.6.4
)
( Linux rajarshi-x550cc 4.15.10-300.fc27.x86_64 #1 SMP Thu Mar 15 17:13:04 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
)
我還安裝了 Jupyter Notebook。 當我在 Jupyter Notebook 上運行新內核時,無論我選擇運行 Python-2 內核還是 Python-3 內核,都只運行 Python-3 內核。 我已經用print(sys.version)
檢查了這一點。
我在 Stackoverflow 上得到了幾個不錯的答案,但沒有一個對我有用。 我使用以下代碼在/usr/share/jupyter/kernels/python2的 Jupyter 庫中創建了一個 JSON 文件:
{
"display_name": "Python 2",
"language": "python",
"argv": [
"python",
"-m",
"ipykernel_launcher",
"-f",
"{connection_file}"
]
}
但沒有明顯的區別。
然后我從 Python 3 中卸載了 Jupyter,如下所示: python3 -m pip uninstall jupyter
但 Jupyter 仍然存在,它仍然只能識別 Python 3。
老實說,我無計可施。 我應該完全刪除 Python 3 嗎?
您可以使用ipykernel
在同一筆記本環境中注冊不同版本的 python。
有關更多信息,請參閱以下文檔https://ipython.readthedocs.io/en/latest/install/kernel_install.html#kernels-for-python-2-and-3
如果我是你,我會完全卸載 python 並繼續如下:
使用 python 2.7 創建虛擬環境
conda create -n python27 python=2.7 anaconda
如果我想要帶有 python 3.6 的 jupyter notebook,我會運行jupyter notebook
activate python27
python27 然后jupyter notebook
。 這將使用 python 2.7 啟動筆記本
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.