1. Install virtualenv
安装virtualenv
pip install virtualenv -i https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple/
安装virtualenvwrapper(Linux)
pip install virtualenvwrapper -i https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple/
安装virtualenvwrapper(Windows)
pip install virtualenvwrapper-win -i https://mirrors.aliyun.com/pypi/simple/
2. Use a virtual environment
2.1 Windows platform
Open cmd, cd to a folder,
1.使用当前目录当做虚拟文件夹
virtualenv . # 执行完之后会自动创建一些virtualenv需要的文件
2.激活虚拟环境
.\Scripts\activate
3.退出虚拟环境(先deactivate退出)
deactivate
4.删除虚拟环境
rmvirtualenv XXX(虚拟环境名)
2.2 Linux platform
Open terminal
1.创建虚拟环境
mkvirtualenv 虚拟环境名,例如:
mkvirtualenv demo
2.查看已创建的虚拟环境
workon 两次tab键
3.选择已创建的虚拟环境
workon 虚拟环境名
4.退出虚拟环境
deactivate
5.删除虚拟环境
rmvirtualenv 虚拟环境名
Note: If a virtual environment is successfully activated, "Virtual Environment Name" will appear at the top of the prompt
3. Install Django
Activate the virtual environment first, otherwise it will be installed on the real environment. You can specify the version when installing, such as installing version 2.2.5, specifying domestic sources will increase the download speed
pip install django==2.2.5 -i https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple/