Skip to content

Commit 748f07e

Browse files
committed
revamped setup instructions
1 parent f83fb79 commit 748f07e

File tree

2 files changed

+67
-49
lines changed

2 files changed

+67
-49
lines changed

python-numpy-tutorial.md

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -40,28 +40,30 @@ You can also find an [IPython notebook version of this tutorial here](https://gi
4040
Table of contents:
4141

4242
- [Python](#python)
43-
- [Basic data types](#python-basic)
44-
- [Containers](#python-containers)
45-
- [Lists](#python-lists)
46-
- [Dictionaries](#python-dicts)
47-
- [Sets](#python-sets)
48-
- [Tuples](#python-tuples)
49-
- [Functions](#python-functions)
50-
- [Classes](#python-classes)
43+
- [Python versions](#python-versions)
44+
- [Basic data types](#basic-data-types)
45+
- [Containers](#containers)
46+
- [Lists](#lists)
47+
- [Dictionaries](#dictionaries)
48+
- [Sets](#sets)
49+
- [Tuples](#tuples)
50+
- [Functions](#functions)
51+
- [Classes](#classes)
5152
- [Numpy](#numpy)
52-
- [Arrays](#numpy-arrays)
53-
- [Array indexing](#numpy-array-indexing)
54-
- [Datatypes](#numpy-datatypes)
55-
- [Array math](#numpy-math)
56-
- [Broadcasting](#numpy-broadcasting)
53+
- [Arrays](#arrays)
54+
- [Array indexing](#array-indexing)
55+
- [Datatypes](#datatypes)
56+
- [Array math](#array-math)
57+
- [Broadcasting](#broadcasting)
58+
- [Numpy Documentation](#numpy-documentation)
5759
- [SciPy](#scipy)
58-
- [Image operations](#scipy-image)
59-
- [MATLAB files](#scipy-matlab)
60-
- [Distance between points](#scipy-dist)
60+
- [Image operations](#image-operations)
61+
- [MATLAB files](#matlab-files)
62+
- [Distance between points](#distance-between-points)
6163
- [Matplotlib](#matplotlib)
62-
- [Plotting](#matplotlib-plotting)
63-
- [Subplots](#matplotlib-subplots)
64-
- [Images](#matplotlib-images)
64+
- [Plotting](#plotting)
65+
- [Subplots](#subplots)
66+
- [Images](#images)
6567

6668
<a name='python'></a>
6769

@@ -91,7 +93,8 @@ print(quicksort([3,6,8,10,1,2,1]))
9193
There are currently two different supported versions of Python, 2.7 and 3.5.
9294
Somewhat confusingly, Python 3.0 introduced many backwards-incompatible changes
9395
to the language, so code written for 2.7 may not work under 3.5 and vice versa.
94-
For this class all code will use Python 3.5.
96+
97+
**For this class all code will use Python 3.7**.
9598

9699
You can check your Python version at the command line by running
97100
`python --version`.

setup.md

Lines changed: 44 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3,50 +3,65 @@ layout: page
33
title: Setup Instructions
44
permalink: /setup-instructions/
55
---
6+
- [Working remotely on Google Cloud](#working-remotely-on-google-cloud)
7+
- [Working locally on your machine](#working-locally-on-your-machine)
8+
- [Anaconda virtual environment](#anaconda-virtual-environment)
9+
- [Python venv](#python-venv)
10+
- [Installing packages](#installing-packages)
611

7-
## Setup
8-
You can work on the assignment in one of two ways: locally on your own machine, or on a virtual machine on Google Cloud.
12+
You can work on the assignment in one of two ways: **locally** on your own machine, or **remotely** on a Google Cloud virtual machine (VM).
913

10-
### Working remotely on Google Cloud (Recommended)
14+
### Working remotely on Google Cloud
15+
As part of this course, you can use Google Cloud for your assignments. We recommend this route for anyone who is having trouble with installation set-up, or if you would like to use better CPU/GPU resources than you may have locally. Please see the set-up tutorial [here](https://github.com/cs231n/gcloud/) for more details.
1116

12-
**Note:** after following these instructions, you can skip the **Working locally** section.
17+
**Note:** after following these instructions, you may skip the remaining sections.
1318

14-
As part of this course, you can use Google Cloud for your assignments. We recommend this route for anyone who is having trouble with installation set-up, or if you would like to use better CPU/GPU resources than you may have locally. Please see the set-up tutorial [here](https://github.com/cs231n/gcloud/) for more details. :)
19+
### Working locally on your machine
20+
If you wish to work locally, you should use a virtual environment. You can install one via Anaconda (recommended) or via Python's native `venv` module. Ensure you are using Python 3.7 as **we are no longer supporting Python 2**.
1521

16-
### Working locally
22+
#### Anaconda virtual environment
23+
We strongly recommend using the free [Anaconda Python distribution](https://www.anaconda.com/download/), which provides an easy way for you to handle package dependencies. Please be sure to download the Python 3 version, which currently installs Python 3.7. The neat thing about Anaconda is that it ships with [MKL optimizations](https://docs.anaconda.com/mkl-optimizations/) by default, which means your `numpy` and `scipy` code benefit from significant speed-ups without having to change a single line of code.
1724

18-
**Installing Anaconda:**
19-
If you decide to work locally, we recommend using the free [Anaconda Python distribution](https://www.anaconda.com/download/), which provides an easy way for you to handle package dependencies. Please be sure to download the Python 3 version, which currently installs Python 3.7. We are no longer supporting Python 2.
25+
Once you have Anaconda installed, it makes sense to create a virtual environment for the course. If you choose not to use a virtual environment (strongly not recommended!), it is up to you to make sure that all dependencies for the code are installed globally on your machine. To set up a virtual environment called `cs231n`, run the following in your terminal:
2026

21-
**Anaconda Virtual environment:**
22-
Once you have Anaconda installed, it makes sense to create a virtual environment for the course. If you choose not to use a virtual environment, it is up to you to make sure that all dependencies for the code are installed globally on your machine. To set up a virtual environment, run (in a terminal)
23-
24-
`conda create -n cs231n python=3.7 anaconda`
27+
```bash
28+
conda create -n cs231n python=3.7
29+
```
2530

26-
to create an environment called `cs231n`.
31+
To activate and enter the environment, run `conda activate cs231n`. To deactivate the environment, either run `conda deactivate cs231n` or exit the terminal. Note that every time you want to work on the assignment, you should rerun `conda activate cs231n`.
2732

28-
Then, to activate and enter the environment, run
33+
You may refer to [this page](https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html) for more detailed instructions on managing virtual environments with Anaconda.
2934

30-
`source activate cs231n`
35+
**Note:** If you've chosen to go the Anaconda route, you can safely skip the next section and move straight to [Installing Packages](#installing-packages).
3136

32-
To exit, you can simply close the window, or run
37+
<a name='venv'></a>
38+
#### Python venv
3339

34-
`source deactivate cs231n`
40+
As of 3.3, Python natively ships with a lightweight virtual environment module called [venv](https://docs.python.org/3/library/venv.html). Each virtual environment packages its own independent set of installed Python packages that are isolated from system-wide Python packages and runs a Python version that matches that of the binary that was used to create it. To set up your `cs231` venv for the course, run the following:
3541

36-
Note that every time you want to work on the assignment, you should run `source activate cs231n` (change to the name of your virtual env).
42+
```bash
43+
# create a virtual environment called cs231n
44+
# that will use version 3.7 of Python
45+
python3.7 -m venv cs231n
46+
source cs231n/bin/activate # activate the virtual env
47+
48+
# sanity check that the path to the python
49+
# binary matches that of the virtual env.
50+
which python
51+
# for example, on my machine, this prints
52+
# $ '/Users/kevin/cs231n/bin/python'
53+
```
3754

38-
You may refer to [this page](https://conda.io/docs/user-guide/tasks/manage-environments.html) for more detailed instructions on managing virtual environments with Anaconda.
55+
<a name='packages'></a>
56+
#### Installing packages
3957

40-
**Python virtualenv:**
41-
Alternatively, you may use python [virtualenv](http://docs.python-guide.org/en/latest/dev/virtualenvs/) for the project. To set up a virtual environment, run the following:
58+
Once you've **setup** and **activated** your virtual environment (via `conda` or `venv`), you should install the libraries needed to run the assignments using `pip`. To do so, run:
4259

4360
```bash
44-
cd assignment1
45-
sudo pip install virtualenv # This may already be installed
46-
virtualenv -p python3 .env # Create a virtual environment (python3)
47-
# Note: you can also use "virtualenv .env" to use your default python (please note we support 3.6)
48-
source .env/bin/activate # Activate the virtual environment
49-
pip install -r requirements.txt # Install dependencies
50-
# Work on the assignment for a while ...
51-
deactivate # Exit the virtual environment
61+
# again, ensure your virtual env has been activated
62+
# before running the commands below
63+
cd assignment1 # cd to the assignment directory
64+
pip install -r requirements.txt # install assignment dependencies
65+
# work on the assignment for a while ...
66+
deactivate # deactivate the virtual env
5267
```

0 commit comments

Comments
 (0)