且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Installing the required software

更新时间:2022-08-12 10:41:39

  1. Installing Python on Mac OSX
    • Installing virtualenv
      $ pip3 install virturalenv -- 安装虚拟环境
      $ virtualenv ENV -- 创建自己的虚拟环境,会创建如图下的目录结构
      virtualenv-15.0.3
      Installing the required software
      Paste_Image.png

使用虚拟环境的原因:

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
  1. Installing Django
    $ pip3 install Django==1.10.3 -- 安装Django不指定版本的话安装最新版本
    验证是否安装成功
    $ django-admin.py --version
    显示版本表示安装成功
Installing the required software
Paste_Image.png

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>
Installing the required software
Paste_Image.png

注意:我们只是用了pip3安装了django,所以启动时使用命令python3 manage.py runserver,如果使用python manage.py runserver会报异常提示未安装django