Upgrade to Pro — share decks privately, control downloads, hide ads and more …

A brief introduction to djangobook and virtualenv

Sponsored · Ship Features Fearlessly Turn features on and off without deploys. Used by thousands of Ruby developers.

A brief introduction to djangobook and virtualenv

A brief introduction to djangobook ch2 and virtualenv/pythonbrew

Avatar for samuelololol

samuelololol

May 28, 2013
Tweet

Other Decks in Technology

Transcript

  1. Brief Introduction to DjangoBook & Virtualenv Ch2. Getting Started, and

    virtualenv Samuel Chen, aka. samuelololol May 28, 2013 samuelololol Brief Introduction to DjangoBook & Virtualenv May 28, 2013 1 / 14
  2. Who Am I Samuel Chen(samuelololol) @TrendMicro 2-3 Years in Python

    Lab Data Crawler: BeautifulSoup Web framework: bottle.py Now: Studying Pyramid/Django samuelololol Brief Introduction to DjangoBook & Virtualenv May 28, 2013 2 / 14
  3. Who Am I Samuel Chen(samuelololol) @TrendMicro 2-3 Years in Python

    Lab Data Crawler: BeautifulSoup Web framework: bottle.py Now: Studying Pyramid/Django samuelololol Brief Introduction to DjangoBook & Virtualenv May 28, 2013 2 / 14
  4. Who Am I Samuel Chen(samuelololol) @TrendMicro 2-3 Years in Python

    Lab Data Crawler: BeautifulSoup Web framework: bottle.py Now: Studying Pyramid/Django samuelololol Brief Introduction to DjangoBook & Virtualenv May 28, 2013 2 / 14
  5. Who Am I Samuel Chen(samuelololol) @TrendMicro 2-3 Years in Python

    Lab Data Crawler: BeautifulSoup Web framework: bottle.py Now: Studying Pyramid/Django samuelololol Brief Introduction to DjangoBook & Virtualenv May 28, 2013 2 / 14
  6. Who Am I Samuel Chen(samuelololol) @TrendMicro 2-3 Years in Python

    Lab Data Crawler: BeautifulSoup Web framework: bottle.py Now: Studying Pyramid/Django samuelololol Brief Introduction to DjangoBook & Virtualenv May 28, 2013 2 / 14
  7. Who Am I Samuel Chen(samuelololol) @TrendMicro 2-3 Years in Python

    Lab Data Crawler: BeautifulSoup Web framework: bottle.py Now: Studying Pyramid/Django samuelololol Brief Introduction to DjangoBook & Virtualenv May 28, 2013 2 / 14
  8. Who Am I Samuel Chen(samuelololol) @TrendMicro 2-3 Years in Python

    Lab Data Crawler: BeautifulSoup Web framework: bottle.py Now: Studying Pyramid/Django samuelololol Brief Introduction to DjangoBook & Virtualenv May 28, 2013 2 / 14
  9. Outline 1 VirtualEnv virtualenv pythonbrew pip 2 DjangoBook Ch2 Getting

    Started samuelololol Brief Introduction to DjangoBook & Virtualenv May 28, 2013 3 / 14
  10. VirtualEnv virtualenv Virtualenv Install ‘virtualenv‘ from the package system of

    the distribution (Linux) Install the package within the ‘virtualenv‘ environment Run the program in ‘virtualenv‘ environment (development & production) samuelololol Brief Introduction to DjangoBook & Virtualenv May 28, 2013 4 / 14
  11. VirtualEnv virtualenv using virtualenv commands $ virtualenv –note-site-packages env $

    cd env && source bin/activate (ENV)$ pip install packages –note-site-packages Do not give access to the global site-packages dir to the virtual environment 0http://virtualenvwrapper.readthedocs.org/en/latest/ samuelololol Brief Introduction to DjangoBook & Virtualenv May 28, 2013 5 / 14
  12. VirtualEnv virtualenv using virtualenv commands $ virtualenv –note-site-packages env $

    cd env && source bin/activate (ENV)$ pip install packages activate the virtual environment 0http://virtualenvwrapper.readthedocs.org/en/latest/ samuelololol Brief Introduction to DjangoBook & Virtualenv May 28, 2013 5 / 14
  13. VirtualEnv virtualenv using virtualenv commands $ virtualenv –note-site-packages env $

    cd env && source bin/activate (ENV)$ pip install packages virtualenvwrapper1 $ mkvirtualenv env2 (env2)$ workon env1 1http://virtualenvwrapper.readthedocs.org/en/latest/ samuelololol Brief Introduction to DjangoBook & Virtualenv May 28, 2013 5 / 14
  14. VirtualEnv pythonbrew Install pythonbrew commands $ sudo pip install pythonbrew

    $ pythonbrew install samuelololol Brief Introduction to DjangoBook & Virtualenv May 28, 2013 7 / 14
  15. VirtualEnv pythonbrew Install pythonbrew commands $ sudo pip install pythonbrew

    $ pythonbrew install $HOME/.bashrc ... [[ -s ¨$HOME/.pythonbrew/etc/bashrc¨ ]] && source ¨$HOME/.pythonbrew/etc/bashrc samuelololol Brief Introduction to DjangoBook & Virtualenv May 28, 2013 7 / 14
  16. VirtualEnv pythonbrew Using pythonbrew Python Version Switch commands $ pythonbrew

    install 2.7.3 $ pythonbrew switch 2.7.3 $ pythonbrew list $ pythonbrew use 2.7.3 samuelololol Brief Introduction to DjangoBook & Virtualenv May 28, 2013 8 / 14
  17. VirtualEnv pythonbrew Using pythonbrew Python Version Switch commands $ pythonbrew

    install 2.7.3 $ pythonbrew switch 2.7.3 $ pythonbrew list $ pythonbrew use 2.7.3 version Switched to Python-2.7.3 samuelololol Brief Introduction to DjangoBook & Virtualenv May 28, 2013 8 / 14
  18. VirtualEnv pythonbrew Using pythonbrew Python Version Switch commands $ pythonbrew

    install 2.7.3 $ pythonbrew switch 2.7.3 $ pythonbrew list $ pythonbrew use 2.7.3 samuelololol Brief Introduction to DjangoBook & Virtualenv May 28, 2013 8 / 14
  19. VirtualEnv pythonbrew Using pythonbrew Python Version Switch commands $ pythonbrew

    install 2.7.3 $ pythonbrew switch 2.7.3 $ pythonbrew list $ pythonbrew use 2.7.3 version Using ‘Python-2.7.3‘ samuelololol Brief Introduction to DjangoBook & Virtualenv May 28, 2013 8 / 14
  20. VirtualEnv pythonbrew Using pythonbrew virtualenv Virtualenv supported commands $ pythonbrew

    venv init $ pythonbrew venv create venv name -p 2.7.3 $ pythonbrew venv list $ pythonbrew venv use venv name samuelololol Brief Introduction to DjangoBook & Virtualenv May 28, 2013 9 / 14
  21. VirtualEnv pythonbrew Using pythonbrew virtualenv Virtualenv supported commands $ pythonbrew

    venv init $ pythonbrew venv create venv name -p 2.7.3 $ pythonbrew venv list $ pythonbrew venv use venv name output Creating ‘ venv name ‘ environment into ˜ /.pythonbrew/venvs/Python-2.7.3 samuelololol Brief Introduction to DjangoBook & Virtualenv May 28, 2013 9 / 14
  22. VirtualEnv pythonbrew Using pythonbrew virtualenv Virtualenv supported commands $ pythonbrew

    venv init $ pythonbrew venv create venv name -p 2.7.3 $ pythonbrew venv list $ pythonbrew venv use venv name samuelololol Brief Introduction to DjangoBook & Virtualenv May 28, 2013 9 / 14
  23. VirtualEnv pythonbrew Using pythonbrew virtualenv Virtualenv supported commands $ pythonbrew

    venv init $ pythonbrew venv create venv name -p 2.7.3 $ pythonbrew venv list $ pythonbrew venv use venv name prompt ( venv name )$ samuelololol Brief Introduction to DjangoBook & Virtualenv May 28, 2013 9 / 14
  24. VirtualEnv pip Using pip pip: https://pypi.python.org/pypi/virtualenv commands $ (env) pip

    freeze requirements.txt $ (env) pip install -r requirements.txt export PIP DOWNLOAD CACHE2 requirements.txt (env)$ pip freeze Cython==0.16 Django==1.4.5 ... 2stackoverflow samuelololol Brief Introduction to DjangoBook & Virtualenv May 28, 2013 10 / 14
  25. VirtualEnv pip Using pip pip: https://pypi.python.org/pypi/virtualenv commands $ (env) pip

    freeze requirements.txt $ (env) pip install -r requirements.txt export PIP DOWNLOAD CACHE2 requirements.txt (env)$ pip freeze Cython==0.16 Django==1.4.5 ... 2stackoverflow samuelololol Brief Introduction to DjangoBook & Virtualenv May 28, 2013 10 / 14
  26. VirtualEnv pip Using pip pip: https://pypi.python.org/pypi/virtualenv commands $ (env) pip

    freeze requirements.txt $ (env) pip install -r requirements.txt export PIP DOWNLOAD CACHE2 2stackoverflow samuelololol Brief Introduction to DjangoBook & Virtualenv May 28, 2013 10 / 14
  27. django ch2 Install Django Django Book Link: http://django-book.readthedocs.org/en/latest/chapter02.html steps virtualenv

    install django add .pth file start project runserver (development mode) 2.pth: http://www.djangoproject.com/r/python/site-module/ samuelololol Brief Introduction to DjangoBook & Virtualenv May 28, 2013 11 / 14
  28. django ch2 Install Django Django Book Link: http://django-book.readthedocs.org/en/latest/chapter02.html steps virtualenv

    install django git trunk pip install django add .pth file start project runserver (development mode) commands $ git clone https://github.com/django/django djmaster $ pip install django tarball: download 2.pth: http://www.djangoproject.com/r/python/site-module/ samuelololol Brief Introduction to DjangoBook & Virtualenv May 28, 2013 11 / 14
  29. django ch2 Install Django Django Book Link: http://django-book.readthedocs.org/en/latest/chapter02.html steps virtualenv

    install django add .pth file start project runserver (development mode) site-packages/django.pth /home/user/djmaster 2.pth: http://www.djangoproject.com/r/python/site-module/ samuelololol Brief Introduction to DjangoBook & Virtualenv May 28, 2013 11 / 14
  30. django ch2 Install Django Django Book Link: http://django-book.readthedocs.org/en/latest/chapter02.html steps virtualenv

    install django add .pth file start project runserver (development mode) command (ENV)$ django-admin.py startproject mysite 2.pth: http://www.djangoproject.com/r/python/site-module/ samuelololol Brief Introduction to DjangoBook & Virtualenv May 28, 2013 11 / 14
  31. django ch2 Install Django Django Book Link: http://django-book.readthedocs.org/en/latest/chapter02.html steps virtualenv

    install django add .pth file start project runserver (development mode) mysite —– manage.py —– mysite init .py settings.py urls.py wsgi.py 2.pth: http://www.djangoproject.com/r/python/site-module/ samuelololol Brief Introduction to DjangoBook & Virtualenv May 28, 2013 11 / 14
  32. django ch2 Install Django Django Book Link: http://django-book.readthedocs.org/en/latest/chapter02.html steps virtualenv

    install django add .pth file start project runserver (development mode) (ENV)$ python manage.py runserver mysite —– manage.py —– mysite init .py settings.py urls.py wsgi.py 2.pth: http://www.djangoproject.com/r/python/site-module/ samuelololol Brief Introduction to DjangoBook & Virtualenv May 28, 2013 11 / 14
  33. django ch2 Install Django Django Book Link: http://django-book.readthedocs.org/en/latest/chapter02.html steps virtualenv

    install django add .pth file start project runserver (development mode) commands (ENV)$ python manage.py runserver 8080 (ENV)$ python manage.py runserver 0.0.0.0:8080 2.pth: http://www.djangoproject.com/r/python/site-module/ samuelololol Brief Introduction to DjangoBook & Virtualenv May 28, 2013 11 / 14
  34. django ch2 database packages PostgreSQL: psycopg, psycopg23 SQLite3: default supported

    MySQL: mySQLdb4 Oracle: cx Oracle5 3http://www.djangoproject.com/r/python-pgsql/ 4http://www.djangoproject.com/r/python-mysql/ 5http://cx-oracle.sourceforge.net/ samuelololol Brief Introduction to DjangoBook & Virtualenv May 28, 2013 12 / 14
  35. django ch2 folder and files django-admin.py mysite/ manage.py mysite/ init

    .py mysite/settings.py mysite/url.py mysite/wsgi.py samuelololol Brief Introduction to DjangoBook & Virtualenv May 28, 2013 13 / 14
  36. django ch2 Thank You Thank You! samuelololol Brief Introduction to

    DjangoBook & Virtualenv May 28, 2013 14 / 14