170k views
2 votes
How to set default python version windows

User Alesi
by
8.5k points

1 Answer

3 votes

Final answer:

To set the default Python version on Windows, you must modify the 'Path' variable in the system's environment variables to include the directory of the preferred Python version at the top of the list. A system restart is not necessary; verification can be done using the 'python --version' command in the command prompt.

Step-by-step explanation:

To set the default Python version on Windows, you'll need to adjust your system's environment variables. Here's a step-by-step guide:

  1. Right-click on the 'This PC' or 'Computer' icon on your desktop, and choose 'Properties'.
  2. Click on 'Advanced system settings' and then click on 'Environment Variables'.
  3. In the 'System Variables' section, find the 'Path' variable and select it, then click 'Edit'.
  4. You'll see a list of directories. If you have multiple Python versions installed, identify the directory for the Python version you want to set as default.
  5. Move the directory for your preferred Python version to the top of the list. This will direct the system to use this version by default.
  6. Click 'OK' to save your changes and close all remaining windows.
  7. Open the command prompt and type python --version to verify that the default Python version is the one you've selected.

Note: If Python is not already in your system's Path, you will need to add the executable's directory to the list following a similar process to the steps listed above. Be careful when modifying system environment variables, as incorrect settings can affect other software.

User Till Ulen
by
7.9k points