python中home定义是什么_Python: PYTHONHOME和PYTHONPATH的区别

Python: PYTHONHOME和PYTHONPATH的区别

目录

PYTHONHOME和PYTHONPATH的区别

6.1.2. 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 variable sys.path. sys.path is initialized from these locations:

The directory containing the input script (or the current directory when no file is specified).

PYTHONPATH (a list of directory names, with the same syntax as the shell variable PATH).

The installation-dependent default.

当导入名为spam的模块时,解释器首先搜索具有该名称的内置模块。如果没有找到,它会搜索一个名为spam.py的文件。变量sys.path. sys给出的目录列表中的py。路径是从这些位置初始化的:

包含输入脚本的目录(或未指定文件时的当前目录)。

PYTHONPATH(一个目录名列表,与shell变量PATH具有相同的语法)。

installation-dependent默认。

Note:On file systems which support symlinks, the directory containing the input script is calculated after the symlink is followed. In other words the directory containing the symlink is not added to the module search path.

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.

注意:在支持符号链接的文件系统上,包含输入脚本的目录是在符号链接之后计算的。换句话说,包含符号链接的目录没有添加到模块搜索路径中。初始化之后,Python程序可以修改sys.path。包含正在运行的脚本的目录位于搜索路径的开头,在标准库路径的前面。这意味着将加载该目录中的脚本,而不是库目录中的同名模块。除非是有意替换,否则这是一个错误。有关更多信息,请参见标准模块一节。

​​​​​​​

sys.path

sys.path 包含输入模块的目录名列表,并且当前目录也是sys.path的一部分。

标签:Python,PYTHONPATH,PYTHONHOME,sys,模块,directory,path,目录

来源: https://blog.csdn.net/qq_41185868/article/details/106220574

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值