Python中的搜索路径

1. 当前目录

2. 环境变量PYTHONPATH中的目录

3. Python安装目录(for Linux OS:/usr/local/lib/python

When a module named spam is imported, the interpreter search for a file named spam.py in the current directory

and then in list of directoried specified by the enviroment variable PYTHONPATH. This has the same syntax as the shell variable PATH, that is, a list of directory names. When PYTHONPATH is not set, or when the file is not found there, the search continues in an installation-dependent default path; on Unix, this is usually(/usr/local/lib/python)

Work for fun,Live for love!
原文地址:https://www.cnblogs.com/allenblogs/p/1845770.html