簡體   English   中英

模塊錯誤:Vscode 中的 Jupyter Notebook 找不到 Numpy 和類似模塊

[英]Module Error: Jupyter Notebook in Vscode cannot find Numpy and similar modules

我已經在 vscode 中安裝了 jupyter notebook 擴展,kernel 和 pip 也使用終端安裝了 jupyter 庫,但是在嘗試在 Z0F41247ED1502B5504C 中的 vscode 中導入 jupyter notebook 中的 jupyter 庫時仍然存在錯誤。

我已經閱讀了多個堆棧溢出帖子和在線博客,但在我的情況下無濟於事。 我正在使用 python 3.9。

原因是 Jupyter 中使用的 python 與 VS Code 終端中使用的 python 不一樣。

在 VS Code 中,Jupyter 使用的 python 環境可以獨立於 VS Code 使用的 python(如 VS Code 左下角所示)。

解決方案:

In the lower left corner of VS Code, select the same python environment as in Jupyter, and then use the shortcut key Ctrl+Shift+` to open a new terminal, it will automatically enter the selected environment, and then use " pip install numpy "安裝模塊。

檢查 python 環境:“ python --version

在此處輸入圖像描述

檢查“numpy”模塊:“ pip show numpy

在此處輸入圖像描述

參考: VS Code 中的 Jupyter

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM