Q.H.
Q.H.

Reputation: 1466

How to start Visual Studio Code within Anaconda Env

I am running into trouble running a python program inside visual studio code on my Windows 10 PC.

When I start a python session from the terminal and say import cv2 I get no errors:

enter image description here

When I go through the command prompt and start VSCode from within the env, I get the ModuleNotFoundError

enter image description here

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

When I try to run the program as python gui.py from within the environment my command prompt crashes with the error message:

enter image description here

I'm not sure how to ask this question other than wondering is there a way to start my IDE from within the python env so that it can locate all the local packages.

Upvotes: 10

Views: 42769

Answers (2)

mohammedFnesh
mohammedFnesh

Reputation: 11

  1. open anaconda prompot
  2. activate your enviroment //activate your_env
  3. write "code" then Enter

Upvotes: 1

Manjeet
Manjeet

Reputation: 969

  1. Make sure you have visual studio code installed in your system.
  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. To Launch VS code from Anaconda/Window command prompt type code. (see below image)

enter image description here

Upvotes: 21

Related Questions