Here are some ways to get started with Python, either online or by installing it on your own computer. The two recommended options are to use the online servers provided or to install Anaconda
on your own machine.
Next>
and confirm.smithj1
) and click Next>
. You must correctly enter your macid at this stage.Go
button next to this courseThe very simplest way to use Python is to go to http://mcmaster.syzygy.ca, log in with your MacID and password, and open a new “Python 3” notebook.
If you want to use a script + console interface (this will be explained in class and tutorial), go to http://mcmaster.syzygy.ca/jupyter/user-redirect/lab, then:
File
> New
> Text File
Rename
the file to <myfile>.py
(where <myfile>
is whatever you want to name your script, e.g. week1_stuff.py
). (Do not include spaces or punctuation other than _
in your file name.)File
> New Console for Editor
, open a “Python 3” consoleWhen accessing the server you might get an error like this:
In general it should be OK to ignore it and try again.
Anaconda
Anaconda
is a complete Python “stack” (i.e., a set of programs and utilities) that has everything you will need for the class, including Spyder
(a script + console environment) and a way to run notebooks.
uname -m
in the Terminal (to open a terminal on the Mac, type Command-Shift-u
to open Utilities; type t
to select Terminal
; double-click to open the terminal [or type Command-Option-o
])x86_64
means “64-bit”, i686
means “32-bit” (if you have to guess, it’s likely that you have a 64-bit version)note: During the installation process you can skip the “Install Microsoft VS Code” step.
New > Python3
If you’re new to computing and not interested in other nuts and bolts, you can stop here!
If you’re running Linux or Mac OSX and are comfortable in the terminal, you can get the basic Python 3.7 stack and use your favourite text editor to work with .py
files.
… that’s it
Note: the installer will also install the latest version of Python 2, which will be the default if you run it from the terminal using python
. To avoid this either run python using python3
or make an alias in your .bash_profile
from python to the Python 3.7 executable.
Some recommended Python IDEs. These all require you to install Python separately, so you will also have to install Anaconda or vanilla Python 3.
Really you just need some combination of Python stack (Python/Anaconda) and something to edit plain text with. Heck, you can even use vi
if you’re into that sort of thing. Do not use a regular WYSIWYG text editor like MS Word: you will be opening yourself up to a world of pain.
You can check what version of Python you are using by running this script or by running
python -c "import sys; print(sys.version)"
directly from Terminal.
Anaconda should come with all the packages you will need for this course. To install a Python package on Linux/OSX you can use pip3
(for Python 3.7) as follows:
pip3 install "numpy"
for example, to install the numpy
package. Replace numpy
with whatever package you need.