Lecture slides on G docs
- Install Visual Studio Code aka VS Code aka VSCode aka Code: https://code.visualstudio.com
- Make sure you have Python 3 installed: download here
a. MacOS/Linux:
which python
(you probably already have it installed). If you get Python 2, trywhich python3
and then usepython3
for the rest of this lecture b. Windows: trypython --version
from PowerShell or Windows Terminal
A Python virtual environment (venv) makes it easy to manage dependencies across projects. Dependencies will be installed within the project directory, instead of globally, allowing different projects to independently track different versions of dependencies
- Go to your project directory:
cd your/project/directory
- Create a virtual environment:
python -m venv .venv
- Activate the virtual environment:
- MacOS/Linux:
./.venv/bin/activate
- Windows:
.\.venv\Scripts\activate
(if you run into a permissions error, try this ))
- If you want to leave your virtual environment:
deactivate
For the future, any time you want to use your venv, just use steps 1 and 3.
You'll notice a new directory, .venv
, that includes symlinks to python
and pip
Calling .venv/bin/activate
modifies your Python environment in your current shell session. deactivate
undoes the modifications
When you pip install package
, the package is installed to the .venv
directory
When you import package
, it will first check your .venv
directory
- Call
python
against a Python file:python path/to/python/file.py
- Runs your code all in one shot
- Use the Python interpreter by itself:
python
- Runs your code line-by-line as you press enter
- Jupyter notebook. This is out of scope for this lecture, but it's a great way to tell a story with Python
I will be using VS Code with its integrated terminal from now on.
To get started, head over to part-1-hello-world.md.
Want to keep practicing Python? Here's an incomplete list of some great resources.
- Advent of Code - a coding competition every December (but available year round) with holiday themed challenges
- Code Kata
- Project Euler
- Codewars