pipenv
功能
- 启用真正确定性的构建,同时轻松指定您想要的内容。
- 生成并检查锁定依赖项的文件哈希值。
- 如果
pyenv可用,自动安装所需的Pythons。 - 通过查找
Pipfile,以递归方式自动查找项目。 - 如果不存在
Pipfile,则自动生成。 - 在标准位置自动创建
virtualenv。 - 取消/安装包时,自动将包添加/删除到
Pipfile。 - 自动加载
.env文件(如果存在)。
主要命令是 install, uninstall 和 lock ,它们生成 Pipfile.lock 。这些旨在取代 $ pip 安装使用,以及手动 virtualenv 管理(激活 virtualenv,运行$ pipenv shell)。
基本概念
- 当
virtualenv不存在时,将自动创建。 - 如果没有传递参数进行安装,则将安装指定的所有软件包
[packages]。 - 要初始化
Python3虚拟环境,请运行$ pipenv --three。 - 要初始化
Python2虚拟环境,请运行$ pipenv --two。 - 否则,
virtualenv为默认值。
其他命令
shell将激活virtualenv生成一个shell。run将从virtualenv运行一个给定的命令,并转发任何参数(例如$ pipenv run python)。- 检查断言当前环境是否满足
PEP 508要求。 graph将打印所有已安装依赖项的漂亮图表。
使用
$ pipenv
Usage: pipenv [OPTIONS] COMMAND [ARGS]...
Options:
--where Output project home information.
--venv Output virtualenv information.
--py Output Python interpreter information.
--envs Output Environment Variable options.
--rm Remove the virtualenv.
--bare Minimal output.
--completion Output completion (to be eval'd).
--man Display manpage.
--three / --two Use Python 3/2 when creating virtualenv.
--python TEXT Specify which version of Python virtualenv should use.
--site-packages Enable site-packages for the virtualenv.
--version Show the version and exit.
-h, --help Show this message and exit.
Usage Examples:
Create a new project using Python 3.7, specifically:
$ pipenv --python 3.7
Remove project virtualenv (inferred from current directory):
$ pipenv --rm
Install all dependencies for a project (including dev):
$ pipenv install --dev
Create a lockfile containing pre-releases:
$ pipenv lock --pre
Show a graph of your installed dependencies:
$ pipenv graph
Check your installed dependencies for security vulnerabilities:
$ pipenv check
Install a local setup.py into your virtual environment/Pipfile:
$ pipenv install -e .
Use a lower-level pip command:
$ pipenv run pip freeze
Commands:
check Checks for security vulnerabilities and against PEP 508 markers
provided in Pipfile.
clean Uninstalls all packages not specified in Pipfile.lock.
graph Displays currently–installed dependency graph information.
install Installs provided packages and adds them to Pipfile, or (if no
packages are given), installs all packages from Pipfile.
lock Generates Pipfile.lock.
open View a given module in your editor.
run Spawns a command installed into the virtualenv.
shell Spawns a shell within the virtualenv.
sync Installs all packages specified in Pipfile.lock.
uninstall Un-installs a provided package and removes it from Pipfile.
来源:https://www.cnblogs.com/aaronzhou001/p/9830417.html