Reputation: 40
I am using VS Code for the first time, trying to run a .py file. However it is struggling to find the packages I have in conda (no virtual env, just base).
I have changed the Python interpreter so that it's now using "...64-bit (conda)".
I have also added "python.defaultInterpreterPath": "C:\\Users\\username\\anaconda3\\python.exe"
into the JSON settings.
When I then run the file, it finds some packages but not all: it finds os, random and collections but not any others...
Also when I run print(sys.executable)
I get "C:\Users\username\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\python.exe". I think this should instead be pointing towards the python.exe in anaconda3...
Any assistance with accessing my packages in conda would be appreciated!
Upvotes: 1
Views: 1904
Reputation: 8411
"python.defaultInterpreterPath" only works when you first open your workspace. After you changed it, it will be stored in the database.
You need to make sure you have switched the python interpreter to which you want to use. It would be like this:
Upvotes: 0
Reputation: 12295
As always, read the docs:
https://code.visualstudio.com/docs/python/environments#_create-a-conda-environment
It contains several hints of what can go wrong with conda environments in VSCode.
Most important for you: A conda environment has to activated before you can use it and obviously this is not happening in your case. The terminal must show a (base) or (Anaconda3) on the prompt. Just pointing to the python.exe is not good enough.
Upvotes: 1