How To Set Anaconda As Default Python In Windows

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.

  1. 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.
  2. Then add the anaconda python installed directory to the Path environment variable, you can refer to the article How To Set Windows Environment Variables.
  3. But there are 2 types of environment variables, one is User variables, the other is System variables.
  4. 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.
  5. 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.
  6. 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.
  7. 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.
  8. 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

  1. How To Install Anaconda On Linux, Windows, macOS Correctly

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.