问题:点冻结与点列表
比较输出结果可发现差异:
user@user-VirtualBox:~$ pip list
feedparser (5.1.3)
pip (1.4.1)
setuptools (1.1.5)
wsgiref (0.1.2)
user@user-VirtualBox:~$ pip freeze
feedparser==5.1.3
wsgiref==0.1.2Pip的文档状态
freeze                      Output installed packages in requirements format.
list                        List installed packages.但是什么是“需求格式”?为什么pip list生成的清单比清单更全面pip freeze?
回答 0
使用时virtualenv,可以指定一个requirements.txt文件来安装所有依赖项。
典型用法:
$ pip install -r requirements.txt软件包需要采用特定的格式pip才能理解,即
feedparser==5.1.3
wsgiref==0.1.2
django==1.4.2
...那就是“要求格式”。
在这里,django==1.4.2意味着安装django版本1.4.2(即使最新版本是1.6.x)。如果您未指定==1.4.2,则会安装可用的最新版本。
您可以在“ Virtualenv和pip基础知识 ”以及官方的“ Requirements File Format ”文档中阅读更多内容。
回答 1
为了回答这个问题的第二部分,显示pip list但没有显示的两个软件包pip freeze是setuptools(easy_install)和它们pip本身。
它看起来像pip freeze少了点列表软件包点子本身依赖。您可以使用该--all标志来显示那些软件包。
从文档中:
--all不要在输出中跳过以下软件包:pip,setuptools,distribute,wheel
回答 2
主要区别在于可以将的输出pip freeze转储到requirements.txt文件中,并在以后用于重建“冻结”环境。
换句话说,您可以运行:pip freeze > frozen-requirements.txt在一台计算机上运行 
 ,然后再在另一台计算机上或干净的环境中运行:
 pip install -r frozen-requirements.txt
您将获得与安装原始环境时所安装的依赖项完全相同的相同环境生成了Frozen-requirements.txt。
回答 3
点列表
列出已安装的软件包,包括可编辑的软件包。
点冻结
以需求格式输出已安装的软件包。
因此有两个区别:
- 输出格式, - freeze为我们提供了标准的需求格式,以后可以用来- pip install -r安装需求。
- 输出内容, - pip list包括- pip freeze不包含的可编辑内容。
回答 4
pip list显示所有软件包。
pip freeze示出了包YOU经由安装pip(或pipenv如果使用该工具)在要求的格式命令。
在下面说明创建虚拟信封时已安装setuptools,pip,wheelpipenv shell。这些软件包不是我使用pip以下软件安装的:
test1 % pipenv shell
Creating a virtualenv for this project…
Pipfile: /Users/terrence/Development/Python/Projects/test1/Pipfile
Using /usr/local/Cellar/pipenv/2018.11.26_3/libexec/bin/python3.8 (3.8.1) to create virtualenv…
⠹ Creating virtual environment...
<SNIP>
Installing setuptools, pip, wheel...
done.
✔ Successfully created virtual environment! 
<SNIP>现在回顾与比较,我已经只安装了相应的命令的输出冷LIB和sampleproject(其中胡椒是一个依赖):
test1 % pip freeze       <== Packages I'VE installed w/ pip
-e git+https://github.com/gdamjan/hello-world-python-package.git@10<snip>71#egg=cool_lib
peppercorn==0.6
sampleproject==1.3.1
test1 % pip list         <== All packages, incl. ones I've NOT installed w/ pip
Package       Version Location                                                                    
------------- ------- --------------------------------------------------------------------------
cool-lib      0.1  /Users/terrence/.local/share/virtualenvs/test1-y2Zgz1D2/src/cool-lib           <== Installed w/ `pip` command
peppercorn    0.6       <== Dependency of "sampleproject"
pip           20.0.2  
sampleproject 1.3.1     <== Installed w/ `pip` command
setuptools    45.1.0  
wheel         0.34.2
