1.确保已经安装pip3 install venv
2.新建虚拟环境
python -m venv myenv
3.安装虚拟环境的依赖包
pip install …
4.激活虚拟环境
cd myenv
cd Scripts
activate
激活activate.bat并进入虚拟环境
进入虚拟环境后,命令行前面显示(myenv)
5.在该虚拟环境中开启django项目
cd 到django项目
C:\Users\Season\Desktop\我的编程项目\虚拟环境\myenv\Scripts>cd C:\Users\Season\Desktop\我的编程项目\.....\Django\package
python manage.py runserver启动项目
(myenv) C:\Users\Season\Desktop\我的编程项目\......\Django\package>python manage.py runserver 8080
Watching for file changes with StatReloader
Performing system checks...System check identified no issues (0 silenced).
February 05, 2024 - 22:03:21
Django version 3.2.7, using settings 'pptest.settings'
Starting development server at http://127.0.0.1:8080/
Quit the server with CTRL-BREAK.
6.退出虚拟环境
deactivate
参考文章:https://zhuanlan.zhihu.com/p/657059174