-
Prerequisite
-
Pipenv (Homepage)
requests作者 K e n R e i t z Ken Reitz KenReitz发布于2017.1.22.Windows is a first-class citizen, in our world.
Pipenvis a tool that aims to bring the best of all packaging worlds (bundler, composer, npm, cargo, yern, etc.) to the Python world.It harnesses
Pipfile,pip, andvirtualenvinto one single toolchain.It automatically creates and manages a
virtualenvfor you projects, as well as adds/removes packages from yourPipfileas you install/uninstall packages. It also generates the ever importantPipfile.lock, which is used to produce deterministic builds.Pipenvis primarily meant to provide users and developers of applications with an easy method to setup a working environment.Pipenv集成包管理+虚拟环境,通过Pipfile,Pipfile.lock以实现.针对虚拟环境,不再需要activateanddeactivate -
Installing Pipenv
pip install --user pipx pipx ensurepath pipx install pipenv -
基础用法
详情参见:
Pipenvmanages dependencies on a per-project basis. To install packages, change into your projects’s directory (or just an empty directory for this tutorial) and run:cd project_folder pipenv install requests pipenv shell # activate environment touch script.py pipenv run python script.py pipenv uninstall <package> pipenv --rm # remove the virtualenvPipenvwill install requests library and create aPipfilefor you in your project’s directory. ThePipfileis used to track which dependencies your project needs in case you need to re-install them, such as when you share your projects with others.If it already has a
requirements.txtfile, it will generate aPipfilefile with the requirements and a virtual environment folder, otherwise, it will generate an emptyPipfilefile.If you disliked or changed your mind about somthing that you have installed:
pipenv uninstall <package>To activate the virtual environment that pipenv generated:
pipenv shellto leave the environment:
exitUsing
pipenv runensures that your installed packages are available to your scripts. It’s also possible to spawn a new shell that ensures all commands have access to your installed packages withpipenv shell. -
References
理解pipenv in Python
最新推荐文章于 2024-12-23 14:54:49 发布
本文介绍Pipenv这一Python包管理工具的基本使用方法。Pipenv整合了Pipfile和Pipfile.lock文件来管理依赖项,并自动创建和管理项目的虚拟环境。通过简单的命令行操作,用户可以安装、卸载依赖包并生成确定性的构建环境。
8623

被折叠的 条评论
为什么被折叠?



