zoukankan      html  css  js  c++  java
  • [Django] Get started with Django -- Install python and virtualenv

    Install python3 on MacOS:

    brew install python3

    Come alone with python3, there are also some other tools are installed as well, for examlpe: 'pip, setuptools'...

    We need 'pip' to help us install virtualenv.

    Why virtualenv?

    Main reason is to resolve the libaraies conflict for different django project. So for each project, you should create new virtual env, and install libraries only for this project, NEVER globally!

    Install:

    pip3 install virtualenv

    Before create a new virtual env, we need to check the python3 location:

    which python3

    And in my case, it is:

    /usr/local/bin/python3

    Create new virtual env:

    virtualenv -p /usr/local/bin/python3 myFirstProject

    Go to the env folder we just create and start working on this env:

    cd myFirstProject
    . bin/activate

    Now we are in the virtual env, we can start install django:

    pip install django

    To make sure and get familiar where those libraries are installed, we can go to:

    ls lib/python3.6/site-packages

    And you should be able to find django is there.

    And also you can type:

    python   // type paython
    
    >>> import django   // import django lib
    >>> django.VERSION // see the verison
    
    (1, 10, 5, 'final', 0) // prints out


    Other way to create new env with >python3.3 only:

    python3 -m venv demo

    Deactive you env:

    deactivate

    List all the libararies:

    pip list
  • 相关阅读:
    Golang 函数
    Golang type
    Golang 分支控制和循环
    Golang 字符型
    Golang运算符
    final 和 static 的区别
    Golang标识符命名规则
    Golang值类型与引用类型
    Golang指针
    启动 jvm 参数小总结
  • 原文地址:https://www.cnblogs.com/Answer1215/p/6481974.html
Copyright © 2011-2022 走看看