如何在 Anaconda Env 中启动 Visual Studio Code

2023-11-26

我在 Windows 10 PC 上的 Visual Studio Code 中运行 Python 程序时遇到问题。

当我从终端启动 python 会话并说import cv2我没有收到任何错误:

enter image description here

当我通过命令提示符并启动时VSCode从环境中,我得到ModuleNotFoundError

enter image description here

Traceback (most recent call last): File "gui.py", line 3, in <module> import cv2 ModuleNotFoundError: No module named 'cv2'

当我尝试运行程序时python gui.py在环境中,我的命令提示符崩溃并显示错误消息:

enter image description here

我不知道如何问这个问题,只是想知道是否有一种方法可以从 python 环境中启动我的 IDE,以便它可以找到所有本地包。


  1. 确保你有视觉工作室代码安装在您的系统中。
  2. Make sure your environment variables are configured. (see below image for reference) enter image description here

  3. Go to your Anaconda command prompt, and type code --version (see below image for reference) enter image description here

  4. 从 Anaconda/Window 命令提示符类型启动 VS 代码code。 (见下图)

enter image description here

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如何在 Anaconda Env 中启动 Visual Studio Code 的相关文章