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:
When I go through the command prompt and start VSCode
from within the env, I get the ModuleNotFoundError
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:
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.
From within VS Code, you can create non-global environments, using virtual environments or Anaconda, by opening the Command Palette (Ctrl+Shift+P), start typing the Python: Create Environment command to search, and then select the command. The command presents a list of environment types: Venv or Conda.
Make sure your environment variables are configured. (see below image for reference)
Go to your Anaconda command prompt, and type code --version
(see below image for reference)
To Launch VS code from Anaconda/Window command prompt type code
. (see below image)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With