【问题标题】:Module Error: Jupyter Notebook in Vscode cannot find Numpy and similar modules模块错误:Vscode 中的 Jupyter Notebook 找不到 Numpy 和类似模块
【发布时间】:2021-03-30 17:50:52
【问题描述】:

我已经在 vscode 中安装了 jupyter notebook 扩展,内核和 pip install jupyter library 也使用终端,但在 windows 10 中尝试在 vscode 中的 jupyter notebook 中导入 jupyter 库时仍然存在this 错误。

我已经阅读了多个堆栈溢出帖子和在线博客,但在我的情况下无济于事。我正在使用 python 3.9。

【问题讨论】:

  • 您是否在 jupyter notebook 本身中尝试过 !pip install numpy 等?
  • 我忘了notebook可以用作命令提示符来安装库。我一直在使用 vscode 终端。谢谢!

标签: python python-3.x numpy visual-studio-code jupyter-notebook


【解决方案1】:

原因是Jupyter中使用的python和VS Code终端中使用的python不一样。

在VS Code中,Jupyter使用的python环境可以独立于VS Code使用的python(在VS Code的左下角)。

解决方案:

在VS Code的左下角,选择和Jupyter一样的python环境,然后使用快捷键Ctrl+Shift+`打开一个新的终端,会自动进入选择的环境,然后使用“pip install numpy" 安装模块。

查看python环境:“python --version

检查“numpy”模块:“pip show numpy

参考:Jupyter in VS Code

【讨论】:

    猜你喜欢
    • 2018-04-26
    • 2019-08-14
    • 1970-01-01
    • 1970-01-01
    • 2021-10-27
    • 1970-01-01
    • 2023-01-07
    • 2018-06-27
    相关资源
    最近更新 更多