python的site-packages目录是什么? [英] What is python's site-packages directory?

查看:131
本文介绍了python的site-packages目录是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目录 site-packages 在各种 Python 相关文章中都有提及.它是什么?如何使用?

The directory site-packages is mentioned in various Python related articles. What is it? How to use it?

推荐答案

site-packages 是手动构建的 Python 包的目标目录.当您从源代码构建和安装 Python 包时(使用 distutils,可能通过执行 python setup.py install),您将在 site-packages 中找到已安装的模块 默认.

site-packages is the target directory of manually built Python packages. When you build and install Python packages from source (using distutils, probably by executing python setup.py install), you will find the installed modules in site-packages by default.

有标准位置:

  • Unix(纯)1:prefix/lib/pythonX.Y/site-packages
  • Unix(非纯):exec-prefix/lib/pythonX.Y/site-packages
  • Windows:prefix\Lib\site-packages

1 Pure 表示该模块仅使用 Python 代码.非纯也可以包含 C/C++ 代码.

1 Pure means that the module uses only Python code. Non-pure can contain C/C++ code as well.

site-packages 默认是 Python 搜索路径的一部分,因此安装在那里的模块之后可以轻松导入.

site-packages is by default part of the Python search path, so modules installed there can be imported easily afterwards.

  • Installing Python Modules (for Python 2)
  • Installing Python Modules (for Python 3)

这篇关于python的site-packages目录是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆