What does the path of python mean_python: the difference between PATH, PYTHONPATH and sys.path_weixin_39685697’s blog
python: the difference between PATH, PYTHONPATH and sys.path Common ground All moduels in their path can be imported PATH Some commands in PATH, such as *.exe, can be run directly without explicit paths. When we install some packages for python, some Scripts are installed in the /Scripts folder, if / Scripts folder path is not in PATH, there will be a prompt PYTHONPATH If we use the modules in PYTHONPATH, then before running python, we must add the path to os.environ[‘PYTHONPATH’], after running python, those modules cannot be imported directly sys.path Official document description: A list of strings that specifies the search path for modules. Initialized from the environment variable PYTHONPATH, plus an installation-dependent default. There are two parts when sys.path is initialized: os.environ[‘PYTHONPATH’] and some paths of default installation dependencies (such as the root directory of python installation and pythonxx.zip) The role of sys.path: Different from PYTHONPATH, sys.path can add our module path after python is running, and then directly import We can pass our module path through os.environ[‘PYTHONPATH’] We can give p