How to Fix “Conda Command Not Found” in VS Code on Windows and Mac

If you use conda for Python environment management, you may encounter the frustrating “conda command not found” error when trying to run conda commands in VS Code terminals.

This is often accompanied by IntelliSense and other functionality not working due to the conda executable not being located.

In this comprehensive guide, we’ll explain the leading causes of the conda not found error and walk through various solutions to get conda working properly again in VS Code on both Windows and Mac.

What Causes the “Conda Command Not Found” Error?

The “‘conda’ is not recognized as an internal or external command” error occurs because VS Code cannot locate the conda executable file itself.

There are a few key reasons this can happen after you’ve installed Anaconda or Miniconda:

  • The conda installation folder is not added to your system PATH variable. This prevents VS Code from locating conda.
  • You installed conda but did not restart VS Code after, so the new PATH is not detected.
  • You are calling ‘conda’ from within a conda environment shell instead of a base shell.
  • There are conflicts between multiple Anaconda or Miniconda installs on your system.
  • The conda path saved in settings has been incorrectly set or become outdated.

Understanding why VS Code can’t find conda is the first step to resolving the problem. Now let’s go through fixes for each cause on both Windows and Mac.

How to Fix “Conda command not found” on Windows

Fix 1: Add Conda Path to System Environment Variables

If conda’s installation folder is not added to your PATH, VS Code won’t find the command. To add it:

  1. Open Control Panel > System > Advanced System Settings
  2. Click Environment Variables
  3. Under System Variables, find the PATH entry and click Edit
  4. Click New and add the path to your conda folder, typically C:\ProgramData\Miniconda3
  5. Click OK to save and close any open windows
  6. Restart VS Code

This appends the conda install folder to your PATH variable, allowing conda to be located.

Fix 2: Restart VS Code After Conda Install

If you install conda but don’t restart VS Code, it will still have the old PATH and be unable to find conda.

Simply restart VS Code for it to detect the new conda path you added during installation. The command should then work.

Fix 3: Don’t Call Conda from Inside Environments

When you activate a conda environment with conda activate myenv, conda will only be available within that environment shell afterwards.

Calling just conda from the activated environment shell will fail with the command not found error.

Instead you need to call the full path %MINICONDA_PATH%\condabin\conda or use the base shell.

Fix 4: Remove Conflicting Miniconda/Anaconda Installations

If you have multiple conflicting Miniconda or Anaconda installs on your Windows system, it can lead to confusion over which conda command VS Code is finding in the PATH.

Fully uninstall older versions and leave only the latest install. Then restart VS Code and try again.

Fix 5: Correct Outdated Conda Path in VS Code Settings

Sometimes the conda path saved in VS Code’s settings becomes outdated or incorrect, causing conda command failures.

To update it:

  1. In VS Code, go to File > Preferences > Settings
  2. Search for conda path
  3. Click Edit in settings.json
  4. Update the path to your current conda install folder
  5. Save the settings and restart VS Code

With the proper conda path configured in settings, the conda the command should work again.

How to Fix “Conda command not found” on Mac

The fixes are very similar on Mac. Here are the key steps:

Fix 1: Add Conda Path to .zprofile System Variable

  1. Open Terminal and run sudo nano ~/.zprofile
  2. Add a new line with the path to your conda folder, typically ~/miniconda3/bin
  3. Save and close the file
  4. Run source ~/.zprofile to reload the updated PATH
  5. Restart VS Code

This will append the conda path to the list of directories where the system searches for commands.

Fix 2: Restart VS Code After Conda Install

As on Windows, make sure to fully restart VS Code after installing conda for the first time. This loads the new PATH.

Fix 3: Call Full Conda Path From Environments

When conda environments are activated on Mac, you need to use the full path to conda rather than just conda like:


Fix 4: Remove Duplicate Conda Installs

Check for any old Anaconda or Miniconda folders at /opt/anaconda* or ~/anaconda* and delete if the installs conflict.

Fix 5: Update Conda Path in VS Code Settings

On Mac the path likely starts with ~/ to point to your user folder. Update it to the current install under File > Preferences > Settings.

How to Permanently Set Environment Variables on Windows

To avoid issues locating conda in the future, you can permanently add the install path to your Windows user or system environment variables.

For all users:

  1. Open Control Panel > System > Advanced System Settings
  2. Click Environment Variables > System Variables
  3. Highlight the PATH entry and click Edit
  4. Click New and add the full path to your conda folder

This sets the PATH at the system-level so all users and applications can locate conda.

For current user:

  1. Search for Edit Environment Variables in the Start Menu
  2. Under User Variables click New
  3. Name the variable CONDA_PATH and set the value to your conda install path

This configures conda just for your Windows user account rather than system-wide.

How to Permanently Set Environment Variables on Mac

To avoid having to re-add the conda path on Mac, add it to your PATH in either ~/.profile or ~/.zprofile:

Set globally for all users:

  1. Open Terminal
  2. Run sudo nano /etc/paths
  3. Add a new line with the path to your conda bin folder such as /Users/myname/miniconda3/bin
  4. Save and close the file

This adds it to the global PATH, though requires providing your password via sudo.

For just your Mac user account:

  1. Run nano ~/.zprofile
  2. Add the path as a new line, like export PATH="~/miniconda3/bin:$PATH"
  3. Save and close the file
  4. Run source ~/.zprofile to reload the PATH

The ~/.zprofile only modifies your user PATH, so no need for sudo.

Why Setting Environment Variables Fixes “Conda Command Not Found”

The reason fixing your PATH variables resolves the 'conda' is not recognized error is because that’s how your operating system locates executable commands like conda.

By adding the folder where conda is installed to the PATH list of directories, you are telling your system:

“Hey, here is another place you should look for commands I try to run – add it to the search path!”

This ensures commands invoked from any shell or program will correctly resolve to the conda executable rather than throwing command not found errors.

No matter where you call conda from – whether Terminal, an IDE like VS Code or PyCharm, Jupyter notebooks, etc – it will now be locatable through the PATH variable.

Alternative Ways to Run Conda Commands in VS Code

If you are still not able to resolve the root cause, there are a few workarounds that let you run conda in VS Code:

  • In the VS Code integrated terminal, activate your base conda env first with conda activate base before using conda commands.
  • Use the full path like C:\ProgramData\Miniconda3\condabin\conda instead of just conda
  • Open an Anaconda Prompt or Miniconda Prompt terminal instead of PowerShell or Command Prompt
  • Install the Conda extension for VS Code which sets the path automatically
  • Use Pylance or Jedi instead of Microsoft’s Python extension to avoid PATH issues
  • Create a batch script called conda.bat containing the full path to conda and add that folder to PATH

These can provide temporary relief but fixing your environment variables is best for a complete solution.

Key Takeaways for Fixing Conda Command Not Found

To summarize the key steps covered in this guide:

The conda not found error occurs because VS Code can't locate the conda executable due to PATH issues.
Ensure you add the conda install folder to your PATH variable.
Restart VS Code after installing conda so it detects the new PATH.
When conda environments are activated, use the full conda path rather than just 'conda'.
Remove any duplicate Anaconda or Miniconda installations causing conflicts.
Double check the conda path set in VS Code settings is correct.
Permanently add the path by setting a CONDA_PATH or updating PATH environment variables.
If issues persist, use workarounds like activating base env first or installing alternate extensions.

Following this advice should get the elusive ‘conda’ command functioning again in your VS Code terminal on Windows, Mac, or Linux. Conda provides powerful Python environment management, but only if you can call its command!

Hopefully this guide gave you the specific troubleshooting steps needed to banish the infamous “conda command not found” from your VS Code instance for good. Let me know if any issues persist or if you have any other conda questions!

Leave a Comment