Reputation: 21
I'm trying to use anaconda with visual studio code but keep getting this error message every time I try to run something.
What Iv'e tried/confirmed:
Python 3.9.1 is installed and Iv'e got no problems running codes in VSC when I use the standard enviroment or inside a command terminal.
The version of python the anacoanda says it is using is 3.8.5. Should it be 3.9.1 or is that normal?
Python and anaconda were added to path during installation - Iv'e already made that mastake before.
Presumably anaconda is installed properly. I can access the navigator and command prompt.
Its not the code that Iv'e writen. I tried simply writing print("Hello") and it gives me the same error.
Installed the latest version of anaconda.
Upvotes: 2
Views: 10925
Reputation: 21
The answer to use the correct terminal also helps with PATH problems.
Often I could not find a package installed via pip install and I tried to specify the path with set PATH=%PATH%;C/..., which did not work.
These PATH problems can be solved by selecting the correct terminal (e.g. Interactive-Window --> command prompt).
Upvotes: 0
Reputation: 10372
I have encountered the same problem. The reason is that VS Code uses the powershell terminal by default, but powershell does not activate the conda environment by default.
Therefore, it is recommended that you use the cmd terminal or other terminals that come with the system. (Because in VS Code, the terminal it uses is to integrate the terminal from the system and it not only supports the powershell terminal.)
Solution: for example, switch to using cmd terminal:
Reference: Integrated terminal in VS Code.
Upvotes: 5