Skip to content

Latest commit

 

History

History
90 lines (59 loc) · 2.03 KB

File metadata and controls

90 lines (59 loc) · 2.03 KB

Python Labs

Before entering a specific lab folder:

  1. install the Python venv virtual environment (one line)
  2. activate the Python venv virtual environment (one line)
  3. install common dependencies (one line)
  4. cd into a lab folder and start coding!

Tip: one line version for Mac

python -m venv .venv ; source .venv/bin/activate ; pip install -r requirements.txt

Accept VS Code's offer to select the new Python environment

After you run python -m venv .venv (see instructions below) VS Code may pop up the following, to which we recommend you answer Yes.

Choose Yes

For the curious, you can view the effects of this choice (or change or fix it) from the following:

Command Palette → "Python: Select Interpreter"

You can then adjust as needed, or just observe an cancel with ESC key.

Windows (Command Prompt)

# from .../labs/python, create the virtual environment
python -m venv .venv

# next activate the environment
.venv\Scripts\activate

# command prompt shows (.venv) before the folder path

# now install all dependencies
pip install -r requirements.txt
```console

## Windows (PowerShell)

```PowerShell
# from .../labs/python, create the virtual environment
python -m venv .venv

# next activate the environment
.venv\Scripts\Activate.ps1

# command prompt shows (.venv) before the folder path

# now install all dependencies
pip install -r requirements.txt

If you get an error about execution policies, consider this:

CopySet-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

Mac, Linux

# from .../labs/python, create the virtual environment
python -m venv .venv

# next activate the environment
source .venv/bin/activate

# command prompt shows (.venv) before the folder path

# now install all dependencies
pip install -r requirements.txt

Start Labs

cd lab0
python main.py

Onward!

If you want to be tidy at the end

# from any folder, as long as prompt is still (.venv)
deactivate