各种搜索路径问题

时间:2014-06-06 09:45:30   收藏:0   阅读:250

python中import一个模块时python解释器的搜索目录顺序:

参考python帮助文档

The Module Search Path

When a module named spam is imported, the interpreter first searches for a built-in module with that name. If not found, it then searches for a file named spam.py in a list of directories given by the variablesys.pathsys.path is initialized from these locations:

  • the directory containing the input script (or the current directory).

After initialization, Python programs can modify sys.path. The directory containing the script being run is placed at the beginning of the search path, ahead of the standard library path. This means that scripts in that directory will be loaded instead of modules of the same name in the library directory. This is an error unless the replacement is intended. See section Standard Modules for more information.

这里也有一篇: Understanding imports and PYTHONPATH

 

环境变量

PATH是告诉操作系统到哪些目录里找可执行文件

PYTHONPATH是告诉python解释器到哪些目录去找要加载的模块

 

Windows找DLL的顺序

With both implicit and explicit linking, Windows first searches for "known DLLs", such as Kernel32.dll and User32.dll. Windows then searches for the DLLs in the following sequence:

The directory where the executable module for the current process is located.

参考:msdn

各种搜索路径问题,布布扣,bubuko.com

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!