- Installing Python on Mac OSX
- Installing virtualenv
virtualenv-15.0.3$ pip3 install virturalenv -- 安装虚拟环境 $ virtualenv ENV -- 创建自己的虚拟环境,会创建如图下的目录结构
- Installing virtualenv
使用虚拟环境的原因:
1. for example, if one of your web applications requires
one version of the library and another application,
due to some legacy or compatibility issues, r
equires another version of the same library,
or if changes made in one library or
application break the rest of the applications
2. Virtualenv can be used to avoid such problematic situations.
It will create its own environment so that
it will not mess with your global settings.
It usually creates its own directories and
shared libraries to make virtualenv work
without any external interference
- Installing Django
验证是否安装成功$ pip3 install Django==1.10.3 -- 安装Django不指定版本的话安装最新版本
显示版本表示安装成功$ django-admin.py --version
django-admin作用说明:
django-admin.py
This utility is the heart of Django's project management facilities,
as it enables the user to do a range of project management tasks, including these:
• Creating a new project
• Creating and managing the project's database
• Validating the current project and testing for errors
• Starting the development web server
启动服务:
$ python3 manage.py runserver 0.0.0.0:<port number>
注意:我们只是用了pip3安装了django,所以启动时使用命令python3 manage.py runserver,如果使用python manage.py runserver会报异常提示未安装django