57

I am beginning to look at python, so when I found a tutorial it said that the first thing to do would be to download python from www.python.org/downloads/

Now when I downloaded python 3, I then started the installation and got to

enter image description here

Why would I want to "Add Python 3.5 to PATH"? What is PATH? Why is it not ticked by default?

Andriy Ivaneyko
  • 20,639
  • 6
  • 60
  • 82
Trajan
  • 1,380
  • 6
  • 20
  • 41
  • 4
    PATH is an environment variable on linux machines, if you add python to it, you will be able to call it simply by "python" or "python3". If you dont add, you will have to use the "real" location. On windows machines however... no clue... I dont think $PATH exists there... Might be something like "Add a shortcut to desktop"? – Gábor Erdős Jan 20 '16 at 12:27
  • It could be compared to the option of adding a shurtcut to the desktop for "regular" applications. It's for convenience – M4rtini Jan 20 '16 at 12:28
  • 5
    @GáborErdős PATH is very much supported on the Windows CLI as well. – tripleee Jan 20 '16 at 12:31
  • 2
    typing python in the terminal\cmd instead of the full path to the python.exe would be the "shortcut" – M4rtini Jan 20 '16 at 12:31
  • Possible duplicate of ["Register" an .exe so you can run it from any command line in Windows](http://stackoverflow.com/questions/4822400/register-an-exe-so-you-can-run-it-from-any-command-line-in-windows) – tripleee Jan 20 '16 at 12:36
  • 1
    @tripleee Definitely not a duplicate. That question is not what I wanted to ask. The answer may be similar, the question is not – Trajan Jan 20 '16 at 12:37
  • @tripleee my question does not relate to .exe files nor the command line – Trajan Jan 20 '16 at 12:38
  • There ase many questions with the same answer. Unless you don't see how the answers there apply, the duplicate answers your question, too. – tripleee Jan 20 '16 at 12:40
  • 1
    @tripleee thats only obvious if you knew what to do originally – Trajan Jan 20 '16 at 12:42
  • Obviousness is not a factor; avoiding duplicate information is. Arguing here is rather pointless, anyway. If you want to discuss this duplicate nomination, please bring it up on https://meta.stackoverflow.com/ – tripleee Jan 20 '16 at 12:51

3 Answers3

67

PATH is an environment variable in Windows. It basically tells the commandline what folders to look in when attempting to find a file. If you didn't add Python to PATH then you would call it from the commandline like this:

C:/Python27/Python some_python_script.py

Whereas if you add it to PATH, you can do this:

python some_python_script.py

Which is shorter and neater. It works because the command line will look through all the PATH folders for python and find it in the folder that the Python installer has added there.

The reason it's unticked by default is partly because if you're installing multiple versions of Python, you probably want to be able to control which one your commandline will open by default, which is harder to do if both versions are being added to your PATH.

SuperBiasedMan
  • 9,814
  • 10
  • 45
  • 73
9

In addition to what @SuperBiasedMan stated, you can edit your PATH in Windows by hitting Start > Run, then type sysdm.cpl. From there, navigate to Advanced tab and then hit Environment Variables. In the lower section, where it says 'System variables', find the one named PATH and double click it. Note that it would be easier to copy and paste it to a notepad or something. The separator as you can see is a semi-colon. Any path that you add to this variable, will be looked when you type any command in a cmd window or through the 'Run' command line. That's the same concept as in Linux, I just pointed out how it can be edited.

Moshe Vayner
  • 738
  • 1
  • 8
  • 23
1

This shows the way if you haven't add python to PATH(By the way, the python.exe is in my Python directory)
This shows the way if you haven't add python to PATH

This is the way if you add python to a PATH This is the way if you add python to a PA

Boyce Cecil
  • 97
  • 2
  • 8