首页 > 技术文章 > Django框架入门1虚拟开发环境的配置

reblue520 2019-12-16 11:29 原文

1.安装virtualenv虚拟程序

C:\Users\ws>pip install virtualenv

创建名字为testvir的虚拟环境

C:\Users\ws>virtualenv testvir

进入虚拟环境

C:\Users\ws\testvir\Scripts>activate.bat

退出虚拟环境

(testvir) C:\Users\ws\testvir\Scripts>deactivate.bat

2.安装virtualenvwrapper-win环境(更加智能)

C:\Users\ws\testvir\Scripts>pip install virtualenvwrapper-win

创建虚拟环境

C:\Users\ws\testvir\Scripts>mkvirtualenv.bat testvir2

退出虚拟环境testvir2

Workon列出虚拟环境

C:\Users\ws\testvir\Scripts>workon

Pass a name to activate one of the following virtualenvs:

==============================================================================

testvir2

进入虚拟环境testvir2

C:\Users\ws\testvir\Scripts>workon testvir2

(testvir2) C:\Users\ws\testvir\Scripts>

退出

(testvir2) C:\Users\ws\testvir\Scripts>deactivate.bat

# 安装django1.9.8

Cd C:\Users\ws\testvir\Scripts>

Workon testvir2

(testvir2) C:\Users\ws\testvir\Scripts>pip install django==1.9.8

查看django是否安装成功

 

# 在指定路径创建python源码目录,如d:/python目录

# 创建虚拟环境

C:\Users\ws>mkvirtualenv.bat python37_django2

(python37_django2) C:\Users\ws>pip install django==2.1.2

(python37_django2) C:\Users\ws\one>d:

(python37_django2) D:\>cd python

 # 创建app

(python37_django2) D:\python>django-admin startproject one # 查看命令列表

 # 使用pycharm进入虚拟环境

推荐阅读