1.创建项目 新建文件夹startproject 用vscode打开文件夹
2.新建文件夹venv(在终端输入以下代码) 首先切换到cmd
PS D:\Compiles\Python\startproject> python -m venv venv
3.进入虚拟环境
PS D:\Compiles\Python\startproject> venv\Scripts\activate
4.尝试安装一个python库
(venv) PS D:\Compiles\Python\startproject> pip install django
5.创建运行django项目
(venv) PS D:\Compiles\Python\startproject> django-admin startproject mystore
(venv) PS D:\Compiles\Python\startproject> cd mystore
(venv) PS D:\Compiles\Python\startproject\mystore> python manage.py runserver
6.将虚拟环境导出到requirements.txt文件
(venv) PS D:\Compiles\Python\startproject\mystore> pip freeze > requirements.txt
当从网上下载项目后可用以下代码安装虚拟环境
(venv) PS D:\Compiles\Python\startproject\mystore> pip install -r requirements.txt
|