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

DjangoGirls Workshop EuroPython 2016 - Environment setup

vkmc
July 08, 2016

DjangoGirls Workshop EuroPython 2016 - Environment setup

Getting our development environment ready for the Django Girls Workshop in Bilbao for EuroPython 2016. Includes installation of Python 3.4, PIP, Virtualenv and Django for Mac OS X, GNU/Linux and Windows.

vkmc

July 08, 2016
Tweet

More Decks by vkmc

Other Decks in Education

Transcript

  1. DjangoGirls Workshop • Tutorial • Learn basics ◦ Internet ◦

    Programming ◦ Python ◦ Django • Build your very own personal blog • Deploy your personal blog
  2. Save and run your code • Store and manage versioning

    of your code in your code repository. We use Github for that. • Run your code and see your application live. We use PythonAnywhere for that.
  3. Command line Command line interfaces are pretty common when working

    on programming. Your terminal will allow you to view, handle and manipulate files.
  4. Text editor You will be working with a lot of

    different text files, so it’s a good idea to get a text editor. Some options: Notepad++ (Windows) Sublime (Mac OS X) Gedit (Both!)
  5. Python Python is a general-purpose, high-level programming language. Its design

    philosophy emphasizes code readability, and its syntax allows programmers to express concepts in fewer lines of code than would be possible in other languages. $ python >>> print “Hello, world!” Hello, world! >>> exit()
  6. Install Python 3 (Mac OS X) 1. Get Python 3

    from https://www.python. org/downloads/release/python-351/ 2. Double click on the installer and follow the instructions for installing Python 3.5.1 on your Mac. 3. Typing python3 in your shell will open your Python 3 interpreter. Note: Mac OS X comes with Python 2.7 preinstalled. We will be using Python 3 though. Note: More information on how to use Python 3 in Mac OS X can be found in https://docs.python. org/3/using/mac.html
  7. Install Python 3 (GNU/Linux) 1. sudo <pkg-manager> install python<version> •

    Ubuntu 16.04: sudo apt-get install python3.5 • Fedora 23: sudo dnf install python3 • OpenSUSE: sudo zypper install python3
  8. Install Python 3 (Windows) 1. Get Python 3.4 from https://www.python.

    org/downloads/release/python-351/ 2. Double click on the installer and follow the instructions for installing Python 3.4.3 on your Windows. Important: Make sure you remember where you installed (the path) Python Note: More information on how to use Python 3 in Windows can be found in https://docs.python. org/3/using/windows.html
  9. Install Python 3 (Windows) 3. On the "Customize" screen, make

    sure you scroll down to the "Add python.exe to the Path" option and select "Will be installed on local hard drive" 4. Typing python3 in your shell will open your Python 3 interpreter. Important: Make sure you remember where you installed (the path) Python Note: More information on how to use Python 3 in Windows can be found in https://docs.python. org/3/using/windows.html
  10. Python PIP PIP is a package management system used to

    install and manage software packages written in Python. Many packages can be found in the Python Package Index (PyPI). PIP is a recursive acronym that can stand for either "Pip Installs Packages" or "Pip Installs Python". $ pip install some-package-name $ pip uninstall some-package-name $ pip show some-package-name
  11. Install PIP Mac OS X 1. Open a shell 2.

    Run sudo easy_install pip Windows 1. Get PIP from https://pip.pypa.io/en/latest/installing.html 2. Run python get-pip.py Note: Starting from Python versions 2.7.9 and 3.4.0, pip is already included in the regular install
  12. Virtualenv A Virtual Environment is a tool to keep the

    dependencies required by different projects in separate places, by creating virtual Python environments for them. Keeps your global site- packages directory clean and manageable. For example, you can work on a project which requires Django 1.3 while also maintaining a project which requires Django 1.0.
  13. Start a new virtualenv 1. Create and open a new

    directory $ mkdir djangogirls $ cd djangogirls 2. Create the virtualenv $ python3 -m venv myvenv (Mac OS X) $ C:\Python34\python -m venv myvenv (Windows) 3. Start your virtualenv $ source myvenv/bin/activate (Mac OS X) $ myvenv\Scripts\activate (Windows)
  14. Django Django is a free and open source web application

    framework, written in Python. A framework is a set of components that helps you to develop websites faster and easier. Frameworks exist to save you from having to reinvent the wheel and help alleviate some of the overhead when you’re building a new site.
  15. Install Django Now that we have PIP and our virtualenv

    activated, installing Django can be done with: $ pip install django==1.9.0
  16. Run Django 1. Start a new project with $ django-admin

    startproject mysite . (Mac OS X) $ python myvenv\Scripts\django-admin.py startproject mysite . (Windows) 2. Configure the timezone $ gedit mysite/settings.py USE_TZ = False TIME_ZONE = 'Europe/Berlin' Note: You can look for your timezone in http://en.wikipedia.org/wiki/List_of_tz_database_time_zones
  17. Run Django 3. Start the database. We could select the

    database we want by modifying mysite/settings.py. We are going to use the default, sqlite 3. $ python manage.py migrate 4. Start the server $ python manage.py runserver 5. Open a browser and go to 127.0.0.1:8000
  18. Resources Django Girls Tutorial: http://tutorial.djangogirls. org/en/index.html Django Developers Documentation: https://docs.

    djangoproject.com/en/1.8/ Python Developers Documentation: https://www.python.org/doc/