VS Code startup <conda active base> error message

Question:

I just getting started learning with Anaconda on Visual Studio Code. Previously, I only used the Python as an interpreter. After downloaded the Anaconda and upon opening the VS Code I always encounter the following error message.

PS C:UsersuserDocumentsPythonLearn> conda activate base
conda : The term 'conda' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the 
name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ conda activate base
+ ~~~~~
    + CategoryInfo          : ObjectNotFound: (conda:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

I already tried to install and reinstall the anaconda and go through the set environment variable but the error message still exist. The steps I used are as follows.

My Installation Process

  1. Download Anaconda

    • Choice 1: Just Me (recommended)

    • Choice 2 (Advance): Registered Anaconda3 for the system Python 3.9

  2. Add anaconda to environment variable

    • Run "Anaconda Prompt (anaconda3)" as Administrator

    • run where conda

    • Add the directory to the environment variable

    where conda result

  3. Adding the Interpreter path into the VS code

    Adding the interpreter path into the VS code

  4. Testing through a .py file

    • Test#1 – python:

      print("Hello, world")

    Hello world test#1 result

    • Test#2 – library:
    import matplotlib.pyplot as plt
    import matplotlib as mpl
    import numpy as np
    x = np.linspace(0, 20, 100)
    plt.plot(x, np.sin(x))
    plt.show()
    

    For test#2, the terminal produce error message as follows

    PS C:UsersuserDocumentsPythonLearn> & C:/Users/user/anaconda3/python.exe c:/Users/user/Documents/PythonLearn/pytest.py
    C:Usersuseranaconda3libsite-packagesnumpy__init__.py:148: UserWarning: mkl-service package failed to import, therefore Intel(R) MKL initialization ensuring its correct out-of-the box operation under condition when Gnu OpenMP had already been loaded by Python process is not assured. Please install mkl-service package, see http://github.com/IntelPython/mkl-service
      from . import _distributor_init
    Traceback (most recent call last):
      File "C:Usersuseranaconda3libsite-packagesnumpycore__init__.py", line 22, in <module>
        from . import multiarray
      File "C:Usersuseranaconda3libsite-packagesnumpycoremultiarray.py", line 12, in <module>       
        from . import overrides
      File "C:Usersuseranaconda3libsite-packagesnumpycoreoverrides.py", line 7, in <module>
        from numpy.core._multiarray_umath import (
    ImportError: DLL load failed while importing _multiarray_umath: The specified module could not be found.
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "c:UsersuserDocumentsPythonLearnpytest.py", line 3, in <module>
        import matplotlib.pyplot as plt
      File "C:Usersuseranaconda3libsite-packagesmatplotlib__init__.py", line 104, in <module>
        import numpy
      File "C:Usersuseranaconda3libsite-packagesnumpy__init__.py", line 150, in <module>
        from . import core
      File "C:Usersuseranaconda3libsite-packagesnumpycore__init__.py", line 48, in <module>
        raise ImportError(msg)
    ImportError:
    
    IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!
    
    Importing the numpy C-extensions failed. This error can happen for
    many reasons, often due to issues with your setup or how NumPy was
    installed.
    
    We have compiled some common reasons and troubleshooting tips at:
    
        https://numpy.org/devdocs/user/troubleshooting-importerror.html
    
    Please note and check the following:
    
      * The Python version is: Python3.9 from "C:Usersuseranaconda3python.exe"
      * The NumPy version is: "1.21.5"
    
    and make sure that they are the versions you expect.
    Please carefully study the documentation linked above for further help.
    
    Original error was: DLL load failed while importing _multiarray_umath: The specified module could not be found.
    
    PS C:UsersuserDocumentsPythonLearn>
    

Debugging Attempts

  1. Previous Possible Solution: Updating Environment Variable

    I reinstall and updated the new path. Still the command prompt does not recognize the conda within the system. Nevertheless, the system detects Python.

    CMP_Version_Response

  2. Testing If the Anaconda working properly

    I tested the installed Anaconda file if we could detect the version or not in the directory that the Anaconda lies in. The system did detect the installed version of Anaconda.

    Anaconda Exist


Ending Note / Updates

Does anyone encounter a similar problem for this error? What are your recommended solutions?

Thank you in advance for your responses. I will keep you posted If I find a solution for this.

Update#1: Restart, Re-open, Re-select path, Update
I have update the Anaconda through conda update conda and conda update anacondain the Anaconda terminal. Alongside restart the computer and re-open the terminal. Still, the error codes still exists (Error Code below) whenever I open the VS code.

. : File C:UsersuserDocumentsWindowsPowerShellprofile.ps1 cannot be loaded because running scripts is disabled on this system. For more        
information, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170.
At line:1 char:3
+ . 'C:UsersuserDocumentsWindowsPowerShellprofile.ps1'
+   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : SecurityError: (:) [], PSSecurityException
    + FullyQualifiedErrorId : UnauthorizedAccess
PS C:UsersuserDocumentsPythonLearn> conda activate base
conda : The term 'conda' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or 
if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ conda activate base
+ ~~~~~
    + CategoryInfo          : ObjectNotFound: (conda:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException
 
PS C:UsersuserDocumentsPythonLearn> 

       
Asked By: Jira.Lee

||

Answers:

Have you installed conda while VS Code still opened?

VS Code terminal does not update it’s PATH, initialization of PATH comes at start of terminal same goes for CMD.

My only solution is to re-open VS Code or start a new terminal in terminal section in navbar inasmuch as you have conda installed on Windows and CMD confirmed it

Interpreter path updates periodically.

Answered By: Gren Man

Solution: Clean Uninstall, Reinstall with Advance Selection

Shout out for Gren Man for the solution. The steps are as follows.

  1. Clean Uninstall anaconda

    • ‘conda install anaconda-clean’ –> run ‘anaconda-clean –yes’
    • Then go to "add or remove programs" –> uninstall Anaconda3 –> Restart Computer
  2. Reinstall

  3. Testing and Vertifying

    • Run the print("Hello, world") –> Checking Python [Passed]
    • Run the library test (see above) –> Checking Library [Passed]

Additional Notes

Selection of the "Add PATH" choice will add the path as follows into the system. Which are discoverable by the VS Code. The added paths are different form calling where conda and manually add them into the Environment Variables yourself.

Answered By: Jira.Lee
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.