安装 Pipenv Pipenv 是一个生产流的工具,旨在将最好的打包世界( bundler, composer, npm, cargo, yarn, etc. )带入 Python 世界。它将 Pipfile、pip 和 virtualenv 整合到一个命令中。 我们可以使
安装 Pipenv
Pipenv 是一个生产流的工具,旨在将最好的打包世界( bundler, composer, npm, cargo, yarn, etc. )带入 Python 世界。它将 Pipfile、pip 和 virtualenv 整合到一个命令中。
我们可以使用 pip 命令安装 pip3 install --user pipenv:
$ pip3 install --user pipenvCollecting pipenv
Downloading pipenv-2022.5.2-py2.py3-none-any.whl (3.9 MB)
|████████████████████████████████| 3.9 MB 634 kB/s
Collecting virtualenv-clone>=0.2.5
Downloading virtualenv_clone-0.5.7-py3-none-any.whl (6.6 kB)
Requirement already satisfied: certifi in /usr/lib/python3/dist-packages (from pipenv) (2019.11.28)
Collecting pip>=22.0.4
Downloading pip-22.1.2-py3-none-any.whl (2.1 MB)
|████████████████████████████████| 2.1 MB 2.3 MB/s
Requirement already satisfied: setuptools>=36.2.1 in /usr/lib/python3/dist-packages (from pipenv) (45.2.0)
Requirement already satisfied: virtualenv in /usr/lib/python3/dist-packages (from pipenv) (20.0.17)
Installing collected packages: virtualenv-clone, pip, pipenv
Successfully installed pip-22.1.2 pipenv-2022.5.2 virtualenv-clone-0.5.7
为什么推荐使用 pipenv,因为它会自动为您的项目创建和管理虚拟环境 virtualenv,并在您安装/卸载包时从您的 Pipfile 中添加/删除包。它还生成非常重要的 Pipfile.lock,用于生成确定性构建。
安装 Django
创建一个项目文件夹 mytodo :
$ mkdir mytodo$ cd mytodo
Django 是一个高级 Python Web 框架,它鼓励快速开发和简洁、实用的设计。它由经验丰富的开发人员构建,解决了 Web 开发的大部分麻烦,因此您可以专注于编写应用程序,而无需重新发明轮子。它是免费和开源的。
使用 pipenv install django 在虚拟环境中安装您的 django 框架:
$ sudo pipenv install djangoCreating a virtualenv for this project...
Pipfile: /home/wade/PythonProject/mytodo/Pipfile
Using /usr/bin/python3 (3.8.10) to create virtualenv...
⠼ Creating virtual environment...created virtual environment CPython3.8.10.final.0-64 in 439ms
creator CPython3Posix(dest=/root/.local/share/virtualenvs/mytodo--AJz7sim, clear=False, global=False)
seeder FromAppData(download=False, pip=latest, setuptools=latest, wheel=latest, pkg_resources=latest, via=copy, app_data_dir=/root/.local/share/virtualenv/seed-app-data/v1.0.1.debian.1)
activators BashActivator,CShellActivator,FishActivator,PowerShellActivator,PythonActivator,XonshActivator
✔ Successfully created virtual environment!
Virtualenv location: /root/.local/share/virtualenvs/mytodo--AJz7sim
Creating a Pipfile for this project...
Installing django...
Adding django to Pipfile's [packages]...
✔ Installation Succeeded
Pipfile.lock not found, creating...
Locking [dev-packages] dependencies...
Locking [packages] dependencies...
Building requirements...
Resolving dependencies...
✔ Success!
Updated Pipfile.lock (a6086c)!
Installing dependencies from Pipfile.lock (a6086c)...