Adding to your Environment variables for windows

Environment variables for windows

Adding environment variables is important to know. Environment variables are values that can be stored on your computer that can then be referenced by you computer.

Scenario: Adding python to a windows pc

Setting up python on a windows pc, you will need to make sure there is an environment variable set up to reference the command “python”. This will point to the python executable on your pc.

To view all your environment variables on windows you do the following:

  • Right click on your “My computer” icon
  • Select advanced system settings
  • Click on environment variables

The most common environment variables to edit are the values in the “Path”. This will allow you to point to an executable in a file path.

If for example you have php installed on your pc, but you cannot run php in the command line, you need to update or add the correct filepath to point to the php executable, which is often here: C:\xampp\php

Returning to python, I have python installed here: C:\Python27\Scripts. So I have made sure this file path is in my environment variable “Path”.

Remember to seperate multiple paths with a semi colon ‘;’.

Eg

C:\Python27\Scripts; C:\xampp\php;

This will remain the same for any program you want to run in your command line. If the file path is not in your environment variables you won’t be able to run the program from your command line.

Open a new command line window

You need to open a new command line instance in order to use the environment variable. You won’t be able use the path reference in the same command line window.