Difference between yum and pip

1、Yum

Yum (full name Yellow dog Updater, Modified) is a shell front-end package manager in Fedora and RedHat and CentOS. Based on RPM package management , it can automatically download and install RPM packages from a specified server, automatically handle dependencies, and install all dependent packages at one time, without having to download and install tediously again and again.

2、pip

pip is a tool for installing and managing  Python packages . The tools for python installation packages include easy_install, setuptools, pip, distribute, etc. distribute is an alternative to setuptools and pip is an alternative to easy_install.

3. The difference between warehouse sources

pip depends on the pip repository, the default is: http://pypi.python.org/ , as long as it is there, it can be installed. And yum depends on the yum repository, and needs someone else to make an rpm package before it can be installed.

4. Differences in installation content

yum mainly installs software applications in the linux system, such as nginx, haproxy, mysql, etc.

pip installs modules in python. Since python needs to install quite a few modules, you can use pip to install it. pip can use the install statement to install modules, upgrade modules, and delete modules you installed before.

Source: https://blog.csdn.net/sj349781478/article/details/79158642


Replenish:

Python package management tool

 

There are already many mature packages in the Python environment, which can be installed to extend our program.

For example, many times Python developers will go to the PyPI website to find the package they want to use, and then install it. PyPI (Python Package Index) is a site for obtaining third-party Python packages to complement the standard library.

In the process of installing Python packages, distutils, setuptools, distribute, setup.py, easy_install, easy_install, and pip are often involved.

Suddenly, the package management of Python is messy. What is the relationship between these tools and how should we choose to use them?

The following is a brief introduction to some content related to Python package management.

Python package management tools

With so many Python package management tools, when you first get into Python, you may not know which to choose. In fact, after checking the official documentation of Python, the relationship between these tools was gradually clarified, and there was no such confusion.

The following is a brief introduction to the package management tools in Python.

distutils

distutils is a part of the python standard library. The purpose of this library is to provide a convenient packaging method for developers and a convenient installation method for users.

The setup.py we often use is based on distutils, and then it can be packaged or installed through setup.py.

Looking at a simple example, find a directory and create three files foo.py, bar.py and setup.py, where the contents of setup.py are as follows:

copy code
copy code
from distutils.core import setup
setup(
    name='fooBar',
    version='1.0',
    author='Will',
    author_email='[email protected]',
    url='http://www.cnblogs.com/wilber2013/',
    py_modules=['foo', 'bar'],
)
copy code
copy code

然后,在该目录中运行 python setup.py sdist ,会得到以下输出,同时生成了一个"fooBar-1.0.zip"包。

使用者就可以解压缩这个包然后执行 python setup.py install进行安装,然后就可以使用foo、bar这两个模块了:

关于更过如何编写setup.py的内容,请自行参阅Python官方文档中的setupscript部分

setuptools 和 distribute

setuptools 是对 distutils 的增强,尤其是引入了包依赖管理。我们可以通过ez_setup.py来安装setuptools。

至于distribute,它是setuptools的一个分支版本。分支的原因是有一部分开发者认为 setuptools 开发太慢。但现在,distribute 又合并回了 setuptools 中,所以可以认为它们是同一个东西。

前面看到setup.py可以创建一个压缩包,而setuptools使用了一种新的文件格式(.egg),可以为Python包创建 egg文件。setuptools 可以识别.egg文件,并解析、安装它

easy_install

当安装好setuptools/distribute之后,我们就可以直接使用easy_install这个工具了:

  1. 从PyPI上安装一个包:当使用 easy_install package 命令后,easy_install 可以自动从 PyPI 上下载相关的包,并完成安装,升级
  2. 下载一个包安装:通过 easy_install package.tgz 命令可以安装一个已经下载的包
  3. 安装egg文件:通过 easy_install package.egg 可以安装一个egg格式的文件

通过 easy_install --help 命令可以获取该命令相关的帮助提示:

根据上面的分析,可以看到setuptools/distribute和easy_install之间的关系:

  • setuptools/distribute 都扩展了 distutils,提供了更多的功能
  • easy_install是基于setuptools/distribute的一个工具,方便了包的安装和省级

pip

pip是目前最流行的Python包管理工具,它被当作easy_install的替代品,但是仍有大量的功能建立在setuptools之上。

easy_install 有很多不足:安装事务是非原子操作,只支持 svn,没有提供卸载命令, 安装一系列包时需要写脚本。pip 解决了以上问题,已经成为新的事实标准。

pip的使用非常简单,并支持从任意能够通过 VCS 或浏览器访问到的地址安装 Python 包:

  • 安装:  pip install SomePackage 
  • 卸载:  pip uninstall SomePackage 

文章的下面部分就重点介绍一下pip相关的内容。

使用pip

在大家使用Python中,推荐使用pip进行Python包管理,pip的安装和使用都比较方便。

pip安装

pip的安装有两种常用的方式:

  1. 下载get-pip.py文件,然后执行 python get-pip.py 进行安装(如果没有安装setuptools,那么get-pip.py会帮忙安装)
  2. 现在pip源码包,然后通过setup.py进行安装

pip常用命令

对于pip,最常用的肯定还是 pip --help ,通过帮助文档,就可以大概知道如何使用命令和参数。

pip常用命令集合:

使用

命令

从PyPI安装软件包

pip install SomePackage

卸载软件包

pip uninstall SomePackage

查看以安装软件包

pip list

查看可升级软件包

pip list --outdated

升级软件包

pip install --upgrade SomePackage

查看软件包安装了哪些文件及路径等信息

pip show --files SomePackage

安装软件包的指定版本号

pip install SomePackage

# latest version

 

pip install SomePackage==1.0.4

# specific version

 

pip install 'SomePackage>=1.0.4'

# minimum version

根据依赖文件安装软件包

pip freeze > requirements.txt

# 使用pip导出依赖文件列表

 

pip install -r requirements.txt

# 根据依赖文件列表,自动安装对应的软件包

总结

This article introduces the relationship between various package management tools in Python. I believe that through the introduction of this article, there will be no more confusion about terms such as distutils, setuptools, distribute, setup.py, easy_install, easy_install, and pip.

After a general understanding of these Python package management tools, you should also know how to choose and use them.

This article does not cover how to make and publish a Python package. Interested students can go to the Python official website to check.

Source: https://www.cnblogs.com/liangqihui/p/6895108.html

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324538940&siteId=291194637