简体   繁体   English

使用 Visual Studio Code 时出现 ModuleNotFoundError

[英]ModuleNotFoundError when using Visual Studio Code

I am using a machine I inherited with an Anaconda 3 installation on it.我正在使用我继承的机器,上面安装了 Anaconda 3。 I am trying to complete a Python course, which is my first foray into Python ever.我正在尝试完成 Python 课程,这是我第一次尝试 Python。 When I open a Python interpreter in Command Prompt or PowerShell, and I run the following line, it executes without error.当我在命令提示符或 PowerShell 中打开 Python 解释器时,我运行以下行,它执行没有错误。

(base) PS D:\ProgramData\Anaconda3\Scripts> py
Python 3.7.4 (default, Aug  9 2019, 18:34:13) [MSC v.1915 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import xlsxwriter

Somehow Anaconda is integrated with VS Code, yet when I try and import xlsxwriter in this window, I get the error: Anaconda 以某种方式与 VS Code 集成,但是当我尝试在此 window 中import xlsxwriter时,出现错误:

ModuleNotFoundError: No module named 'xlslwriter'

When this Python interpreter window opens, it shows the following:当这个 Python 解释器 window 打开时,它显示如下:

Jupyter Server URI: http://localhost:8889/?token=b8a07e61e603f9dae0ee599198ac33f68d3f398036f6af0e
Python version:
3.7.6 (default, Jan  8 2020, 20:23:39) [MSC v.1916 64 bit (AMD64)]
(6, 0, 1)
D:\\ProgramData\\Anaconda3\\envs\\py37\\python.exe

If I try installing xlsxwriter with pip , I get a message that如果我尝试使用pip安装xlsxwriter ,我会收到一条消息

Requirement already satisfied: xlsxwriter in d:\programdata\anaconda3\lib\site-packages (1.2.8)

I'm not asking for an instant answer, but guidance on how I can diagnose and correct this problem.我不是要立即回答,而是要指导我如何诊断和纠正这个问题。 Why is the module available to some interpreters (Command Prompt and PowerShell, and Jupyter Notebook) and not available in the VS Code interpreter?为什么该模块对某些解释器(命令提示符和 PowerShell 和 Jupyter Notebook)可用,而在 VS Code 解释器中不可用? How can I use VS Code and or Python functionality to learn about the config of the current environment and such things?如何使用 VS Code 和/或 Python 功能来了解当前环境的配置等?

Based on advice given in this answer , I ran the command根据此答案中给出的建议,我运行了命令

!pip install xlsxwriter

in the VS Code interpreter, and finally, the module was available for import .在 VS Code 解释器中,最后,该模块可用于import

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 ModuleNotFoundError:Visual Studio Code 中没有名为“pyperclip”的模块 - ModuleNotFoundError: No module named 'pyperclip' in Visual Studio Code Visual Studio Code 中 matplotlib 和 pandas 的 ModuleNotFoundError - ModuleNotFoundError for matplotlib and pandas in Visual Studio Code 诗歌问题 - Visual Studio 代码调试中的 ModuleNotFoundError - poetry woes - ModuleNotFoundError in visual studio code debugging 如何使用 Visual Studio Code 修复 python 中的 ModuleNotFoundError - How to fix ModuleNotFoundError in python with Visual Studio Code moduleNotFoundError:没有在 Visual Studio 代码中命名的模块 - moduleNotFoundError: No module named in visual studio code Visual Studio Code ModuleNotFoundError:没有名为“_overlapped”的模块 - Visual Studio Code ModuleNotFoundError: No module named '_overlapped' Visual Studio Code,没有看到 pymongo 'ModuleNotFoundError' 使用 pip 安装了 pymongo。 为什么它看不到pymongo? - Visual Studio Code, not seeing pymongo 'ModuleNotFoundError' installed pymongo using pip. Why does it not see pymongo? Visual Studio Code - ModuleNotFoundError,终端和 VSCode 中的不同 sys.path? - Visual Studio Code - ModuleNotFoundError, different sys.path in terminal and VSCode? ModuleNotFoundError:Visual Studio Code 中没有名为“bs4”的模块 - ModuleNotFoundError: No module named 'bs4' just in Visual Studio Code ModuleNotFoundError:在 Visual Studio 代码中没有我的自定义类型名为“xxx”的模块 - ModuleNotFoundError: No module named 'xxx' with my custom type in Visual Studio code
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM