Skip to content

Instantly share code, notes, and snippets.

@katychuang
Last active December 24, 2015 15:29
Show Gist options
  • Select an option

  • Save katychuang/6820463 to your computer and use it in GitHub Desktop.

Select an option

Save katychuang/6820463 to your computer and use it in GitHub Desktop.
Files for PyLadies Intro to Python 1: Setting up development environment

Getting Started with Python

NYC PyLadies

RSVP at the event page

Agenda for the evening:

  • (Few mins) Introductions around the group and possibly breaking into smaller groups, of 6-8 each.
  • (15-20mins) Attendees will install python (see links below in download links file)
  • (Intermission) Short demonstration of using virtual env and installing packages with a few commands
  • (5-10 mins) Discussion of python 2 vs 3; why it's important to be organized with virtualenv
  • (Assuming there is 30 mins left over) Try the 2 exercises in the gist file. If not enough time it'll be a "take home" exercise.

===

Files in this gist

  • Download links for python
  • Shell script for installing virtualenv
  • Exercises

Exercises for Intro to Python 1: Setting up your development environment

Try these exercises to test your understanding of python installation and working from the command line. Here are some examples for reference.

# Checking Python version 
$ python --version

# Checking path to Python interpreter
$ which python

# Starting a virtual environment. 
# Creating a virtual environment will automatically drop you into it.
$ mkvirtualenv yourvirtualPython2

# Closing virtual environment 
(yourvirtualPython2)$ deactivate

# Installing a virtualenv with Python3 
$ mkvirtualenv -p 'which python3' yourvirtualPython3

# List of virtual environments 
$ workon

# Activating a virtual environment
$ workon yourvirtualPython2

# Deleting a virtual enviroment
$ rm -rf yourvirtualPython2

# Saving list of packages into a file 
$ pip freeze > requirements.txt

# previewing a text file
$ cat requirements.txt

Exercise 1

Create a virtual environment named TheHolyGrail with Python3

  • Install these packages Flask, sqlalchemy, flask-sqlalchemy
  • Work on TheHolyGrail
  • Save the list of installed packages into a file named 'requirements.txt'
  • Exit the virtual environment

Exercise 2

Create a virtual environment named KungFu

  • Install these packages Python 2, pandas
  • Work on KungFu
  • Save the list of installed packages into a file named 'requirements.txt'
  • Exit the virtual environment

To preview the requirements file from the command line, you can type in the bash command cat requirements.txt

#If you're on Mac OSX, install pip with
sudu easy_install pip
# Install virtual environment with this line. The wrapper makes it easier to use.
pip install virtualenv virtualenvwrapper
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment