Setting up a Python Environment
Overview
A Python Environment is a python sandbox that is created on a machine where libraries can be installed locally
within the environment. The environment is isolated from other environments, so that installations in one environment
are not visible to other environments.
This makes it easy to install various versions of a library in different environments.
Setup
The easiest way to setup a Python environment in VSCode is to click ctrl-shit-p, and then select
"Python: Create Environment", then follow the prompts.
This will create an environment where you can install Pythoin libraries, but the installs will be available
only the envirnment.
When you want to run code within the environment, you need to activate it first. Within VSCode, select
File -> Open Folder, and then select the folder where the envirnoment exists. Then click Terminal -> New Terminal.
This will open a new terminal window (from which you can install libraries) and will activate the envirnoment by
default.
An alternative approach is to create a Jupyterh notebook and follow the prompts to create an environment. Click ctrl-shift-p.
Click Jupyter Notebook. VSCode will ask you for which Python kernel to use. Selet new, and then select create an environment. Chooose
the .venv and then skip pakcage installation.
Installing Libraries
To install a library, use the pip install command in a terminal that is running within the activated environment.
pip install QuantLib