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:\Users\user\Documents\PythonLearn> 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
Download Anaconda
Choice 1: Just Me (recommended)
Choice 2 (Advance): Registered Anaconda3 for the system Python 3.9
Add anaconda to environment variable
Run "Anaconda Prompt (anaconda3)" as Administrator
run where conda
Add the directory to the environment variable
Adding the Interpreter path into the VS code
Testing through a .py file
Test#1 - python:
print("Hello, world")
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:\Users\user\Documents\PythonLearn> & C:/Users/user/anaconda3/python.exe c:/Users/user/Documents/PythonLearn/pytest.py
C:\Users\user\anaconda3\lib\site-packages\numpy\__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:\Users\user\anaconda3\lib\site-packages\numpy\core\__init__.py", line 22, in <module>
from . import multiarray
File "C:\Users\user\anaconda3\lib\site-packages\numpy\core\multiarray.py", line 12, in <module>
from . import overrides
File "C:\Users\user\anaconda3\lib\site-packages\numpy\core\overrides.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:\Users\user\Documents\PythonLearn\pytest.py", line 3, in <module>
import matplotlib.pyplot as plt
File "C:\Users\user\anaconda3\lib\site-packages\matplotlib\__init__.py", line 104, in <module>
import numpy
File "C:\Users\user\anaconda3\lib\site-packages\numpy\__init__.py", line 150, in <module>
from . import core
File "C:\Users\user\anaconda3\lib\site-packages\numpy\core\__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:\Users\user\anaconda3\python.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:\Users\user\Documents\PythonLearn>
Debugging Attempts
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.
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.
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 anaconda
in 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:\Users\user\Documents\WindowsPowerShell\profile.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:\Users\user\Documents\WindowsPowerShell\profile.ps1'
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : SecurityError: (:) [], PSSecurityException
+ FullyQualifiedErrorId : UnauthorizedAccess
PS C:\Users\user\Documents\PythonLearn> 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:\Users\user\Documents\PythonLearn>
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.