|
1 | 1 | # Run Juyper Notebook examples using the ORE Python wheels |
2 | 2 |
|
3 | | -This tutorial is aimed at the user who wants to install the ORE |
4 | | -Python module and use it to execute example Jupyter notebooks provided on |
5 | | -https://github.com/OpenSourceRisk/ORE-SWIG. No compilation is necessary. |
| 3 | +This tutorial is aimed at the user who wants to install the pre-built ORE |
| 4 | +Python module and use it to execute example Jupyter notebooks provided in |
| 5 | +[the notebooks directory](https://github.com/OpenSourceRisk/ORE-SWIG/tree/master/OREAnalytics-SWIG/Python/Examples/Notebooks). No compilation is necessary. |
6 | 6 |
|
7 | 7 | [Back to tutorials index](tutorials.00.index.md) |
8 | 8 |
|
9 | 9 | **Please note** that (as of October 2023) the published ORE Python wheels are |
10 | 10 | available for Python versions 3.8 up to 3.11 for Windows, Linux and macOS arm64, |
11 | | -and Python versions up to 3.10 for Intel Mac users. |
| 11 | +and Python versions up to 3.10 for Intel Mac users. |
12 | 12 |
|
13 | | -We assume below that the python executable points to a permissible Python 3 version. |
| 13 | +We assume below that the python executable points to a permissible Python 3 version. You can check your system's default python version with |
14 | 14 |
|
15 | | -## Create a virtual environemnt |
| 15 | + python --version |
16 | 16 |
|
17 | | - python -m venv venv |
| 17 | +## Quick Set Up and First Run |
18 | 18 |
|
19 | | -## Activate the virtual environment (Windows) |
| 19 | +Please note that these steps must be executed sequentially in a single command prompt/shell. The working directory, for ease, should be OREAnalytics-SWIG/Python/Examples/Notebooks. |
20 | 20 |
|
21 | | - CALL .\venv\Scripts\activate.bat |
| 21 | +1. Create a virtual environment: |
22 | 22 |
|
23 | | -## Activate the virtual environment (Linux, Mac) |
| 23 | + ``` python -m venv venv ``` |
24 | 24 |
|
25 | | - source "$(pwd)/venv/bin/activate" |
| 25 | +2. Activate the virtual environment: |
26 | 26 |
|
27 | | -## Upgrade pip |
| 27 | + (Windows): ```.\venv\Scripts\activate.bat ``` |
| 28 | + |
| 29 | + (Linux, Mac): ```source "$(pwd)/venv/bin/activate" ``` |
28 | 30 |
|
29 | | - python -m pip install --upgrade pip |
| 31 | +3. Install required Python modules. The notebook examples require Jupyter, the ORE Python module and a few additional packages for e.g. plotting. To install these in the virtual environment please make sure to execute this **after** activating the virtual environment as above. |
30 | 32 |
|
31 | | -## Install required Python modules |
| 33 | + ``` python -m pip install open-source-risk-engine matplotlib pandas plotly jupyter_server==2.8.0 jupyter ``` |
32 | 34 |
|
33 | | -The Notebook examples require Jupyter, the ORE Python module and a few additional packages. |
| 35 | +4. Launch Jupyter! This opens a browser window that shows the list of Example folders on the left hand side. Double click to change into any of the Example folders and then double click the Jupyter notebook to open. |
34 | 36 |
|
35 | | - python -m pip install open-source-risk-engine pytest matplotlib pandas plotly jupyter_server==2.8.0 jupyter |
| 37 | + ``` python -m jupyterlab ``` |
36 | 38 |
|
37 | | -## Launch Jupyter with reference to the Notebooks directory |
| 39 | +## Normal Usage |
38 | 40 |
|
39 | | - python -m jupyterlab --notebook-dir=/path/to/OREAnalytics-SWIG/Python/Examples/Notebooks |
| 41 | +After the first time run, you simply need to activate the virtual environment and run jupyter lab. |
40 | 42 |
|
41 | | -This opens a browser window that shows the list of Example folders on the left hand side. |
42 | | -Double click to change into any of the Example folders and then double click the Jupyter notebook to open. |
| 43 | + (Windows): ```.\venv\Scripts\activate.bat ``` |
| 44 | + |
| 45 | + (Linux, Mac): ```source "$(pwd)/venv/bin/activate" ``` |
| 46 | + |
| 47 | + python -m jupyterlab |
43 | 48 |
|
44 | 49 | ## Exit the virtual environment |
45 | 50 |
|
46 | | - deactivate |
| 51 | + To deactivate the virtual environment you can simply close the command prompt/terminal window. Othewise you can run the relevant deactivation script (assuming that the working directory is the Notebooks directory: |
47 | 52 |
|
| 53 | + (Windows): ```.\venv\Scripts\deactivate.bat ``` |
| 54 | + |
| 55 | + (Linux, Mac): ```source "$(pwd)/venv/bin/deactivate" ``` |
48 | 56 |
|
0 commit comments