Blog

Technical thoughts, troubleshooting, and development notes.

Blog/Python

Making Conda Available in CMD Without Exposing Python from the Default Environment

After installing Miniconda, the system normally uses its base environment by default and can run Python directly from it, making base very easy to contaminate.

Back
This page's table of contents

Python: Making Conda Accessible in cmd Without Accessing Python Through the Default Environment

Benefits of Doing This

Normally, after installing miniconda, the system picks up miniconda’s base environment as the default environment and can directly use base to run python. This makes the base environment very easy to contaminate

What I need now is for cmd to access the conda command normally, but not python

Step 1

Make sure Python is not installed in the machine’s main environment. Download and install miniconda, choose just me during installation, and do not set environment variables

Step 2

Open a cmd window and enter the absolute path to perform conda init

C:\Users\mengzhishanghun\miniconda3\Scripts\conda.exe init cmd.exe

Open a new cmd window, and you will find that cmd now correctly recognizes conda commands

Step 3

Now enter

conda config --set auto_activate_base false

This disables entering the base environment by default. Now enter where python, and the result is

C:\Users\mengzhishanghun>where python
信息: 用提供的模式无法找到文件。

Thanks for reading. Feel free to like, follow, and bookmark, and discuss any questions in the comments.
If this article helped you, click here to donate and support the author.