官网地址 Pipenv is a production-ready tool that aims to bring the best of all packaging worlds to the Python world. It harnesses Pipfile, pip, and virtualenv into one single command.
# 1. 初始化一个虚拟环境; hhw-4:pythonEnv hhw$ pipenv install Creating a virtualenv for this project… Pipfile: /Users/hhw/Desktop/pythonEnv/Pipfile Using /usr/local/Cellar/pipenv/2018.11.26_2/libexec/bin/python3.7 (3.7.3) to create virtualenv… ⠋ Creating virtual environment...Already using interpreter /usr/local/Cellar/pipenv/2018.11.26_2/libexec/bin/python3.7 Using real prefix '/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7' New python executable in /Users/hhw/.local/share/virtualenvs/pythonEnv-Vx1xxtfj/bin/python3.7 Also creating executable in /Users/hhw/.local/share/virtualenvs/pythonEnv-Vx1xxtfj/bin/python Installing setuptools, pip, wheel... done.
✔ Successfully created virtual environment! Virtualenv location: /Users/hhw/.local/share/virtualenvs/pythonEnv-Vx1xxtfj Creating a Pipfile for this project… Pipfile.lock not found, creating… Locking [dev-packages] dependencies… Locking [packages] dependencies… Updated Pipfile.lock (a65489)! Installing dependencies from Pipfile.lock (a65489)… 🐍 ▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ 0/0 — 00:00:00 To activate this project's virtualenv, run pipenv shell. Alternatively, run a command inside the virtualenv with pipenv run. hhw-4:pythonEnv hhw$
# 3. 新建文件,并运行; # 下载requests模块 hhw-4:pythonEnv hhw$ pipenv install requests Installing requests… Adding requests to Pipfile's [packages]… ✔ Installation Succeeded Pipfile.lock (444a6d) out of date, updating to (a65489)… Locking [dev-packages] dependencies… Locking [packages] dependencies… ✔ Success! Updated Pipfile.lock (444a6d)! Installing dependencies from Pipfile.lock (444a6d)… 🐍 ▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ 5/5 — 00:00:02 To activate this project's virtualenv, run pipenv shell. Alternatively, run a command inside the virtualenv with pipenv run. hhw-4:pythonEnv hhw$ vim test.py
用 ls 命令查看当前项目目录,你会发现有两个文件:Pipfile 和 Pipfile.lock 。