python的路径

python的路径

1、PYTHONHOME


Change the location of the standard Python libraries. By default, the libraries are searched in prefix/lib/pythonversion and exec_prefix/lib/pythonversion, where prefix and exec_prefix are installation-dependent directories, both defaulting to /usr/local.

PYTHONHOME是python库的路径。

When PYTHONHOME is set to a single directory, its value replaces both prefix and exec_prefix. To specify different values for these, set PYTHONHOME to prefix:exec_prefix.

    当prefix、exec_rpefix不一致时,PYTHONHOME设置为 prefix:exec_prefix。

2、PYTHONPATH


Augment the default search path for module files. The format is the same as the shell’s PATH: one or more directory pathnames separated by os.pathsep (e.g. colons on Unix or semicolons on Windows). Non-existent directories are silently ignored.

module的默认搜索路径。

In addition to normal directories, individual PYTHONPATH entries may refer to zipfiles containing pure Python modules (in either source or compiled form). Extension modules cannot be imported from zipfiles.

有可能添加zip文件。

The default search path is installation dependent, but generally begins with prefix/lib/pythonversion (see PYTHONHOME above). It is always appended to PYTHONPATH.

在PYTHOMHOME的基础上添加了/lib/pythonversion。

3、site

  This module is automatically imported during initialization. The automatic import can be suppressed using the interpreter’s -S option.

  Importing this module will append site-specific paths to the module search path and add a few builtins, unless -S was used.

  site模块会被自动加载,site会添加site-specific路径进入module search path。即使-S指定了。

  It starts by constructing up to four directories from a head and a tail part. For the head part, it uses sys.prefix and sys.exec_prefix; empty heads are skipped. For the tail part, it uses the empty string and then lib/site-packages (on Windows) or lib/pythonX.Y/site-packages (on Unix and Macintosh). For each of the distinct head-tail combinations, it sees if it refers to an existing directory, and if so, adds it to sys.path and also inspects the newly added path for configuration files.

  A path configuration file is a file whose name has the form name.pth and exists in one of the four directories mentioned above; its contents are additional items (one per line) to be added to sys.path. Non-existing items are never added to sys.path. No item is added to sys.path more than once. Blank lines and lines beginning with # are skipped. Lines starting with import (followed by space or tab) are executed.

  .pth是路径文件。

4、After these path manipulations, an attempt is made to import a module named sitecustomize, which can perform arbitrary site-specific customizations. It is typically created by a system administrator in the site-packages directory.

5、After this, an attempt is made to import a module named usercustomize, which can perform arbitrary user-specific customizations, if ENABLE_USER_SITE is true. This file is intended to be created in the user site-packages directory (see below), which is part of sys.path unless disabled by -s.

待续。。。

时间: 2024-09-29 23:17:54

python的路径的相关文章

Python搜索路径

转自:http://www.jbxue.com/article/15324.html 在python编程中,模块的导入需要一个叫做"路径搜索"的过程.即在文件系统"预定义区域"中查找 mymodule.py文件(如果你导入 mymodule 的话).这些预定义区域只不过是你的 Python 搜索路径的集合. 默认搜索路径是在编译或是安装时指定的.它可以在一个或两个地方修改.一个是启动 Python 的 shell 或命令行的 PYTHONPATH 环境变量. 该变量

Python之路【第二十四篇】:Python学习路径及练手项目合集

Python学习路径及练手项目合集 Wayne Shi· 2 个月前 参照:https://zhuanlan.zhihu.com/p/23561159 更多文章欢迎关注专栏:学习编程. 本系列Python技术路径中包含入门知识.Python基础.Web框架.基础项目.网络编程.数据与计算.综合项目七个模块.路径中的教程将带你逐步深入,学会如何使用 Python 实现一个博客,桌面词典,微信机器人或网络安全软件等.完成本路径的基础及项目练习,将具备独立的Python开发能力. 完整的Python学

注册表中添加Python安装路径

安装pywin32会要求寻找python安装路径(说实在我没遇到找不到然后安装不上的事儿,姑且先记下来), reference: http://bbs.csdn.net/topics/390512587?page=1 Windows Registry Editor Version 5.00 [HKEY_CURRENT_USER\Software\Python] [HKEY_CURRENT_USER\Software\Python\Pythoncore] [HKEY_CURRENT_USER\So

自定义python模块路径

自定义python模块路径: 如下载好的python模块scons $ tar zxfv scons-3.0.0.tar.gz$ cd scons-3.0.0$ mkdir ~/scons$ python setup.py install --home ~/scons/ $ vi ~/.bashrc export PYTHONPATH=$PYTHONPATH:~/scons:wq$ source ~/.bashrc 原文地址:http://blog.51cto.com/yangzhiming/2

2019版python学习路径图

据了解,在Blender.GIMP等软件的背后,Python图形处理脚本已经在发挥越来越大的作用.如果你看过Blender基金会制作的三部开源动画影片,你甚至还能预期不远的未来,Python终将有一天能够进军好莱坞,成为数字电影制作的一种工具.因此有越来越多的人加入到Python的学习中来.2019版python学习路径图分享给你.有人说Python难,其实只是因为很多人不熟悉python的部署,所以才说难,目前python不是非常普及的原因有两个:第一是会python的程序员较少,从招人就能看

13、python的路径处理

前言:本文主要介绍python中路径的处理,包括os模块和有关的2个魔法变量. 一.os模块 python里面的os模块有许多方法可以让我们通过代码实现创建,删除和更改目录,具体如下: os.getcwd():显示当前的工作路径,只具体到路径,不具体到文件 os.path.realpath(path):返回path的真实路径,如果参数是:file,就说明是本文件所在的绝对路径,对比二者的区别? os.path.join(a,b):连接两个部分的路径,组成一个完整的路径 os.mkdir(路径名字

自定Python模块路径及调用方法

今天自己跟着教材写好了一个函数,添加好注释后保存,准备用来作模块使用. 就在自己满怀激情准备使用一下这个模块的时候,却发现不知道自己的模块要放在哪里,怎么调用…… 经过网上一轮百度后,在其他老鸟的博客里终于找到了相关的方法,在这里小记一下: 临时指定路径可用:impor sys;sys.path.append('/home/XXXX') 添加默认模块搜索路径(我的python为2.7版):在/usr/local/lib/python2.7/dist-packages目录里新建一个.pth文件,把

linux查看python安装路径,版本号

一.想要查看ubuntu中安装的Python路径 方法一:whereis python 方法二:which python 二.想要查看ubuntu中安装的python版本号 python

Python学习路径(整合版)

PS:内容来源于网络 一.简介         Python是一种面向对象.直译式计算机程序设计语言,由Guido van Rossum于1989年底发明.由于他简单.易学.免费开源.可移植性.可扩展性等特点,Python又被称之为胶水语言.下图为主要程序语言近年来的流行趋势,Python受欢迎程度扶摇直上. 二.数据分析路径 由于Python拥有非常丰富的库,使其在数据分析领域也有广泛的应用.由于Python本身有十分广泛的应用,本期Python数据分析路线图主要从数据分析从业人员的角度讲述P