配置django开发环境

修改ubuntu软件源

先备份一下源文件

sudo cp /etc/apt/sources.list /etc/apt/sources.list_bak  
sudo nano /etc/apt/sources.list

删除原来内容,复制以下内容并替换;Ctrl+o保存,Ctrl+x退出;

deb http://mirrors.163.com/ubuntu/ xenial main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ xenial-security main restricted universe 
multiverse
deb http://mirrors.163.com/ubuntu/ xenial-updates main restricted universe     
multiverse
deb http://mirrors.163.com/ubuntu/ xenial-proposed main restricted universe 
multiverse
deb http://mirrors.163.com/ubuntu/ xenial-backports main restricted universe 
multiverse
deb-src http://mirrors.163.com/ubuntu/ xenial main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ xenial-security main restricted universe 
multiverse
deb-src http://mirrors.163.com/ubuntu/ xenial-updates main restricted universe 
multiverse
deb-src http://mirrors.163.com/ubuntu/ xenial-proposed main restricted universe 
multiverse
deb-src http://mirrors.163.com/ubuntu/ xenial-backports main restricted universe 
multiverse

更新下系统

sudo apt-get update
sudo apt-get upgrade

安装pip包管理工具

For Python 3
  sudo apt-get install python3-pip

For Python 2
  sudo apt-get install python-pip

安装python虚拟化环境工具virtualenv

 sudo pip install virtualenv

如果是python3的话将pip改为pip3

--启动virtualenv

新建一个项目目录

 mkdir myproject
 cd myproject/ 

创建虚拟环境

 virtualenv --no-site-packages venv

激活虚拟环境

 source venv/bin/activate
--安装 Django
sudo pip install Django==1.8.16 或者 sudo pip install Django==1.11.8

ps:如果觉得pip下载速度太慢也可更新pip的源
修改 ~/.pip/pip.conf (没有就创建一个),内容如下:

 [global]
 index-url = https://pypi.tuna.tsinghua.edu.cn/simple

退出虚拟环境

deactivate

你可能感兴趣的:(配置django开发环境)