Hi guys,
When I am checking the echo %path% in CMD, it showed the value below:
C:\Anaconda\envs\Version35;C:\Anaconda\envs\Version35\Library\mingw-w64\bin;C:\Anaconda\envs\Version35\Library\usr\bin;C:\Anaconda\envs\Version35\Library\bin;C:\Anaconda\envs\Version35\Scripts;C:\Anaconda\envs\Version35\bin;C:\Anaconda\condabin;C:\Anaconda;C:\Anaconda\Library\mingw-w64\bin.;C:\Users\Matthew\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Python 3.9
My questions are:
- Why there are some folders that is not available in my machine can be appear in the path?
- If one of the path is not accessible, will it continue to run the other paths until the end to execute a code?
- What is the command code to ask python to access a specific path which contain the function I want?
- How to delete the specific path that is not available in my machine ?
- Is adding empty folders just to let the path available and continue to run through its path is a good option? What is the better solution?
Many thanks in advance.
Hi Kheng,
Usually, the system looks for the path specified by echo %path% when it wants to run a command or file. Initially, your system will try to find the executable file in these directories. If it is not found, then it goes to the user-defined paths.
Personally, I do not like to mess with these as it can be a hassle if one fine day, your program stops working.
Sometimes, it can happen that installing a new environment or program can add a file path to the system, but during uninstalling the environment, this path remains there itself. That could be one reason why you are seeing some folders' paths in the "echo %path%" but these folders don't exist in your system.
If you want to delete the path you could first check whether the directory exists using os.path.isfile(path)
Then you can check the environment variables by performing the following steps.
- Right click on My Computer and click on properties.
- Click on Advanced System settings.
- Click on Environment Variable tab.
You might be able to remove the path from here.
Hope this helps.