Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why would I add python to PATH

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?

like image 426
Trajan Avatar asked Jan 20 '16 12:01

Trajan


People also ask

Should you add Python to path?

If you forget to add Python to the PATH variable, you won't be able to run Python in your command line from any other directory. You will get a message saying 'python' is not recognized as an internal or external command .

Why do we set Python path?

So, the only reason to use PYTHONPATH variables is to maintain directories of custom Python libraries that are not installed in the site packages directory (the global default location). In simple terms, it is used by user-defined modules to set the path so that they can be directly imported into a Python program.

What does path mean Python?

PYTHONPATH is an environment variable which the user can set to add additional directories that the user wants Python to add to the sys. path directory list. In short, we can say that it is an environment variable that you set before running the Python interpreter.

What does adding to path mean?

Adding a directory to your PATH expands the # of directories that are searched when, from any directory, you enter a command in the shell.


1 Answers

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.

like image 111
SuperBiasedMan Avatar answered Oct 05 '22 08:10

SuperBiasedMan