I installed Anaconda for my python example code development. And I want to run the Anaconda built-in Python as my default python in the windows command line.
But when I open a dos window and run the command python in it, it either shows the error message ‘python’ is not recognized as an internal or external command, operable program or batch file or run the python which is not anaconda built-in python. This article will tell you how to fix it.
1. How To Make The Anaconda Built-in Python As My Windows Default Python.
- First, you should get the anaconda python installed directory, you can refer to the article How To Find Where Anaconda Python Is Installed. In my environment, the anaconda python installed directory is C:\Users\Jerry\anaconda3.
- Then add the anaconda python installed directory to the Path environment variable, you can refer to the article How To Set Windows Environment Variables.
- But there are 2 types of environment variables, one is User variables, the other is System variables.
- And there is a default Path environment variable in the System variables list, you can add the anaconda python directory path at the beginning of the Path environment variable.
- But after you add and restart a new dos window and run the command python in it, it still shows the error.
C:\Windows\system32>python 'python' is not recognized as an internal or external command, operable program or batch file.
- So you should create a new Path environment variable in the User variables list and add the anaconda python directory to the Path environment variable.
- This time when you open a new dos window and run the command python, it will run the anaconda python that you specified.
C:\Users\Jerry>python Python 3.8.8 (default, Apr 13 2021, 15:08:03) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32 Warning: This Python interpreter is in a conda environment, but the environment has not been activated. Libraries may fail to load. To activate this environment please see https://conda.io/activation Type "help", "copyright", "credits" or "license" for more information.
- You should wonder why the anaconda installed directory is under the C:\User\Jerry folder, this is because when you install the anaconda for windows, you choose the Just Me(recommended) radio button in the anaconda setup Select Installation Type wizard.
References