Git: Use the conda command to switch virtual environments (win10)

Table of contents

1. Problem:In Git on a win10 computer, the conda list command cannot be used. The virtual environment cannot be activated using theconda activate base command.

2. Solution:

1) Solve the problem of using conda command in Git: configure environment variables.

 2) Solve the problem of being unable to activate the virtual environment using the [conda activate environment name] command.


1. Question:

In Git on a win10 computer, the conda list command cannot be used, and an error is reported (bash: conda: command not found). It is also impossible to use the conda activate base command to activate the virtual environment, and an error is reported (bash: conda: command not found).

2. Solution:

1) Solve the problem of using conda command in Git: configure environment variables.

How to use conda command in Git of win10? You need to configure environment variables, add the following path to the environment variable Path (here, my computer is used as an example, you can add it according to your own computer path), and then click OK.

  • 1) Anaconda installation address: D:\Anaconda3
  • 2) Anaconda Script directory: D:\Anaconda3\Scripts
  • 3) Anaconda\Library\bin directory: D:\Anaconda3\Library\bin

 Reopen Git bash and enter the conda list command. The error is no longer reported:

But using theconda activate base command to activate the virtual environment still doesn’t work:

 2) Solve the problem of being unable to activate the virtual environment using the [conda activate environment name] command.

Git bash.

Then enter the following command to enter the virtual environment in Git!

# 方式1:
source activate base          #1)先激活base
conda activate your_env_name  #2) 激活自定义的虚拟环境
conda deactivate              #3) 退出自定义的虚拟环境

# 方式2:
source activate your_env_name            #1)激活自定义的虚拟环境
source deactivate  或者 conda deactivate #2) 退出自定义的虚拟环境

 

 

reference:

Windows using conda command under git bash_weixin_30699831's blog-CSDN blog

Solution to the problem that the conda command cannot be used in Git bash in win10_Easier said than done w's blog-CSDN blog

git bash uses conda command to switch environments_Ye Lizi's Blog-CSDN Blog

Guess you like

Origin blog.csdn.net/weixin_39450145/article/details/126467710