vscode調試python時提示無法將“conda”項識別為 cmdlet、函數、腳本文件或可運行程序的名稱的解決方法
VS調試時提示如下信息:
conda : 無法將“conda”項識別為 cmdlet、函數、腳本文件或可運行程序的名稱。請檢查名稱的拼寫,如果包括路徑,請確保路徑
正確,然後再試一次。
所在位置 行:1 字符: 1
解決辦法:
沒有添加系統變量,所有系統根本識別不了conda命令,找不到位置,所以添加以下系統變量:
添加對應Anaconda環境變量到用戶變量中:(以自己的安裝路徑為準):
我的是:
D:\Anaconda
D:\Anaconda\Scripts
D:\Anaconda\Library\bin
示例見下圖:
添加好後重啟VS即可。
如果重啟vscode調試後提示下面的信息:
PS D:\Python> D:/Anaconda/Scripts/activate
PS D:\Python> conda activate base
CommandNotFoundError: Your shell has not been properly configured to use ‘conda activate‘.
If your shell is Bash or a Bourne variant, enable conda for the current user with
$ echo ". D:\Anaconda/etc/profile.d/conda.sh" >> ~/.bashrc
or, for all users, enable conda with
$ sudo ln -s D:\Anaconda/etc/profile.d/conda.sh /etc/profile.d/conda.sh
The options above will permanently enable the ‘conda‘ command, but they do NOT
put conda‘s base (root) environment on PATH. To do so, run
$ conda activate
in your terminal, or to put the base environment on PATH permanently, run
$ echo "conda activate" >> ~/.bashrc
Previous to conda 4.4, the recommended way to activate conda was to modify PATH in
your ~/.bashrc file. You should manually remove the line that looks like
export PATH="D:\Anaconda/bin:$PATH"
^^^ The above line should NO LONGER be in your ~/.bashrc file! ^^^
把之前的方法在做一遍,這次是把之前那三個路徑添加到系統變量的path下即可。
vscode調試python時提示無法將“conda”項識別為 cmdlet、函數、腳本文件或可運行程序的名稱的解決方法