您的位置:首页 > 编程语言 > Python开发

Ubuntu の Python-Web框架Django 环境安装 V1.1

2016-06-10 17:42 731 查看
因为准备移植博客系统到自己的主机上,所以一直在考虑用什么环境,现在准备试试Django怎么样,于是我使用了这个Django框架来进行的,同样的,留下我的安装心得。Django需要安装Python 3.X的版本,而我这里目前是要求3.4.3,然后使用Pip安装,默认情况下Django是使用SQLLite,但是我准备用MySQL,所以就多了一个MySQL的安装,这里仅做一个初步的介绍,后续如果有进展,再跟进

Python 环境配置

这里需要的Python环境为3.4.3,Python的具体配置方法可以参照我的这篇博客,这里说的很清楚了

Ubuntu の 多版本Python的安装管理与切换

MYSQL安装

1、这里我需要使用mysql,所以需要首先配置mysql,mysql的数据库安装可以参照这里,也是说的很详细了:

Ubuntu の MySQL 数据库服务配置和远程连接使用教程

2、安装完服务以后,需要安装对应的mysql依赖

此处在V1.1时更新,增加缺失的依赖

sudo apt-get install mysql-client
sudo apt-get install python3-dev libmysqlclient-dev
pip install mysqlclient


移除旧版本Django

因为我没有安装过旧版本的DJango,所以并没有具体操作,这里直接留出最后结果来就好。

Remove any old versions of Django¶

If you are upgrading your installation of Django from a previous

version, you will need to uninstall the old Django version before

installing the new version.

If you installed Django using pip or easy_install previously,

installing with pip or easy_install again will automatically take care

of the old version, so you don’t need to do it yourself.

If you previously installed Django using python setup.py install,

uninstalling is as simple as deleting the django directory from your

Python site-packages. To find the directory you need to remove, you

can run the following at your shell prompt (not the interactive Python

prompt):

$ python -c “import django; print(django.path)”

安装PIP

1、首先下载安装pip的脚本,记得自己先找好下载的地方

wget https://bootstrap.pypa.io/get-pip.py


2、执行安装脚本

python get-pip.py


通过Pip安装DJango

使用PIP进行安装

pip install Django


安装完成后我们验证一下是否安装成功就可以了,使用python引入DJango进行测试一下就可以了

以下代码是在Python环境中执行的,最后的1.9.7为输出,如果有这个输出,就代表成功了

>>> import django
>>> print(django.get_version())
1.9.7


参照

1、官方文档 我是参照官方文档来安装的,其实最简单的安装方式就是按照官方文档来,不容易出错。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息