Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Significance of a PATH explained

Tags:

java

python

c#

path

This is probably a rudimentary question but I am still kinda new to programming and I've wondered for awhile. I've done multiple projects in Python, C#, and Java, and when I try to use new libraries (especially for Python) people always say to make sure its in the right PATH and such. I just followed an online tutorial on how to install Java on a new computer and it rekindled my question of what a path really is. Is the Path just were the programming language looks for a library in the file system? I get kinda confused on what it's significance is. Again, I'm sorry for the wide question, its just something that I've never quite gotten on my own programming.

EDIT: I just wanted to thank everyone so much for answering my question. I know it was a pretty dumb one now that I've finally figured out what it is, but it really helped me. I'm slowly working through as many C#, Java and Python tutorials as I can find online, and it's nice to know I have somewhere to ask questions :)

like image 990
Tyler Jones Avatar asked Nov 29 '13 23:11

Tyler Jones


People also ask

How do you read a path model?

A path model depicts the causal relations between characteristics of interest (variables). In general, path models are read from left to right, with the variables on the left (independent variables) predicting the outcome variable on the right.

How do you write a path analysis?

To conduct a path analysis, simply write the names of variables in square boxes and connect the square boxes with arrows. This will indicate the effect of one on another, similar to regression. Path analysis takes effect in two ways; before and after running the regression.

Why do we use path analysis?

Path analysis can be used to analyze models that are more complex (and realistic) than multiple regression. It can compare different models to determine which one best fits the data. Path analysis can disprove a model that postulates causal relations among variables, but it cannot prove causality.


2 Answers

The PATH is an environment variable which the shell (or other command interpreter) uses to search for commands. Usually (always?) commands are found with a greedy algorithm, so entries that come first in the PATH are returned first. For example, a command in /usr/local/bin will override a command in /usr/bin given a PATH such as

$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

while the purpose is consistent, the syntax is slightly different on WINDOWS - you would use

C:\> ECHO %PATH%

to "echo" your PATH.

First my shell is going to search /usr/local/sbin then /usr/local/bin then /usr/sbin and then /usr/bin before searching /sbin and /bin if the command isn't found then it will report that it couldn't find such a command...

# Like so
$ thisprogramdoesntexist
thisprogramdoesntexist: command not found

Now, on Linux at least, there's also a LD_LIBRARY_PATH which the system will use to search for dynamic libraries (greedily), on Windows I think it just uses the PATH. Finally, Java uses a CLASSPATH which is similar (but used to search for classes and JARs).

On Linux one might add an entry to the PATH like so,

$ export PATH="$PATH:/addNewFolder"

While on Windows you might use

set PATH=%PATH%;c:\addNewFolder

Sometimes, you might manipulate your PATH(s) to enable specific functionality, see update-java-alternatives on Ubuntu for an example.

like image 151
Elliott Frisch Avatar answered Sep 20 '22 23:09

Elliott Frisch


A PATH is a file directory on your computer. If you need to install a programming language, you might need to put it in your system PATH variable. This means that the system looks to these files for different information, IE where the libraries for the code you are using are.
Hope that helped!

like image 32
Sir_Mr_Bman Avatar answered Sep 20 '22 23:09

Sir_Mr_Bman