◎知识点
概述和安装
pipenv使用
使用pipenv时的项目交接
1.概述
virtualenv和virtualenvwrapper实现了Python第三方库的有效管理,但是仍然存在一些可以改进的地方。比如:requirements.txt的功能较弱,在requirements.txt中仅仅列出了虚拟环境中安装的所有第三方库的名称和版本号, 没有反应出第三库之间的依赖关系。再比如:requirements.txt需要手动生成和更新。要手动的执行 pip3 freeze > requirements.txt 才能得到requirements.txt。如果安装或卸载了第三方库,需要再次执行指令以得到更新的requirements.txt。再比如: pip和virtualenv是两个独立的工具,能和成一个工具是不是更好呢? 第三方库 Pipenv: Python Development Workflow for Humans 就是综上所述的改进工具,pip + virtualenv的结合体,也是Python官方推荐的第三方库管理工具。
Pipenv is a tool that aims to bring the best of all packaging worlds (bundler, composer, npm, cargo, yarn, etc.) to the Python world. Windows is a first-class citizen, in our world.
It automatically creates and manages a virtualenv for your projects, as well as adds/removes packages from your Pipfile as you install/uninstall packages. It also generates the ever-important Pipfile.lock, which is used to produce deterministic builds.
The problems that Pipenv seeks to solve are multi-faceted:
You no longer need to use pip and virtualenv separately. They work together.
Managing a requirements.txt file can be problematic, so Pipenv uses the upcoming Pipfile and Pipfile.lock instead, which is superior for basic use cases.
Hashes are used everywhere, always. Security. Automatically expose security vulnerabilities.
Give you insight into your dependency graph (e.g. $ pipenv graph).
Streamline development workflow by loading .env files.
➜ ~ pip3 install pipenv ➜ ~ ln -s /Users/anzhihe/Library/Python/3.8/bin/pipenv /usr/local/bin/pipenv ➜ ~ 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. --man Display manpage. --support Output diagnostic information for use in GitHub issues. --site-packages / --no-site-packages Enable site-packages for the virtualenv. [env var: PIPENV_SITE_PACKAGES] --python TEXT Specify which version of Python virtualenv should use. --clear Clears caches (pipenv, pip). [env var: PIPENV_CLEAR] -q, --quiet Quiet mode. -v, --verbose Verbose mode. --pypi-mirror TEXT Specify a PyPI mirror. --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 PyUp Safety 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. requirements Generate a requirements.txt from Pipfile.lock. run Spawns a command installed into the virtualenv. scripts Lists scripts in current environment config. shell Spawns a shell within the virtualenv. sync Installs all packages specified in Pipfile.lock. uninstall Uninstalls a provided package and removes it from Pipfile. update Runs lock, then sync. upgrade Resolves provided packages and adds them to Pipfile, or (if no packages are given), merges results to Pipfile.lock verify Verify the hash in Pipfile.lock is up-to-date.
哇哦 你的二维码会跳舞哦
@36tx.com 哈哈,css shake