PATH value explained

This is probably a rudimentary question, but I'm still new to programming, and for a while I wondered. I have done several projects in Python, C # and Java, and when I try to use new libraries (especially for Python), people always say to make sure they are in the correct PATH, etc. I just followed an online tutorial on how to install Java on a new computer, and it again unleashed my question about which path really is. Is the Way only that the programming language is looking for a library in the file system? I'm a little confused about what matters. Again, I apologize for the broad question, its just what I never got from my own programming.

EDIT: I just wanted to thank everyone for answering my question. I know that now it was pretty stupid, that I finally understood what it was, but it really helped me. I am slowly working with such tutorials in C #, Java and Python that I can find on the Internet, and I am pleased to know that I have to ask questions somewhere :)

+4
source share
5 answers

PATH is the directory of files on your computer. If you need to set a programming language, you may need to set it in the PATH variable of the system. This means that the system searches for these files for various information, IE, where are the libraries for the code you use.
Hope this helps!

+1

PATH - , shell ( ) . (?) , PATH . , /usr/local/bin /usr/bin PATH,

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

, WINDOWS -

C:\> ECHO %PATH%

"" PATH.

/usr/local/sbin, /usr/local/bin, /usr/sbin, /usr/bin /sbin /bin, , , " t โ€‹โ€‹...

# Like so
$ thisprogramdoesntexist
thisprogramdoesntexist: command not found

, Linux, LD_LIBRARY_PATH, (), Windows , PATH. , Java CLASSPATH, ( JAR).

Linux PATH, ,

$ export PATH="$PATH:/addNewFolder"

Windows

set PATH=%PATH%;c:\addNewFolder

PATH (s), , . update-java-alternatives Ubuntu .

+2

, , PATH - , , , . .

, python C:\Python27. , , python python script.py.

, , python.exe , , .

, :

$ PATH

Windows, , - . "", "". ! PATH, , .

Python, PATH python.exe pythonversion_number.exe. ! :

$ python26 script.py
$ python33 script2.py

, ,

, !

0

PATH - , ( ), . SET PATH =........

- , , , , .

, PATH

SET PATH=%path%;C:\PROGRAM FILES\MYTOOLFOLDER;

, PATH (%PATH%) (C:\PROGRAM FILES\MYTOOLFOLDER).

Then the tool, when it needs to find a specific file or library, can read the values โ€‹โ€‹of the PATH symbol, split them into semicolons and iteratively look at the directories listed below, looking for the required library.

In C # programming, for example, the tool code may contain something like this

string pathSymbol = Environment.GetEnvironmentVariable("PATH");
string[] pathFolders = pathSymbol.Split(';');
foreach(string folder in pathFolders)
{
    if(File.Exists(Path.Combine(folder, "mylibrary.dll"))
    {
        ..... do whatever you need to do with the file
    }
}

This example assumes a Windows environment.

0
source

All Articles