码迷,mamicode.com
首页 > 其他好文 > 详细

各种搜索路径问题

时间:2014-06-06 09:45:30      阅读:250      评论:0      收藏:0      [点我收藏+]

标签:c   style   blog   a   http   ext   

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).
  • PYTHONPATH (a list of directory names, with the same syntax as the shell variable PATH).
  • the installation-dependent default.

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.

  • The current directory.
  • The Windows system directory. The GetSystemDirectory function retrieves the path of this directory.
  • The Windows directory. The GetWindowsDirectory function retrieves the path of this directory.
  • The directories listed in the PATH environment variable.

参考:msdn

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

各种搜索路径问题

标签:c   style   blog   a   http   ext   

原文地址:http://www.cnblogs.com/wxz888/p/3767370.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!