[英]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.