|
24 | 24 | "- How to load the correct .NET runtime and add the DLL reference from Python.\n", |
25 | 25 | "- How to run a quick sanity check and diagnose common setup issues.\n", |
26 | 26 | "\n", |
| 27 | + "## Virtual Python Environment\n", |
| 28 | + "Before we get to Numerics, we need to ensure Python is up and running on your device and in these notebooks. In the top right hand corner of this notebook click on the **\"Select Kernel\"** button. A Python environment should be available for you to chose from, assuming you've downloaded Python. If you have Python on your computer, but cannot find a Python kernel to select, don't worry we have a solution. We will create and virtual Python environment just for this library to work with.\n", |
| 29 | + "\n", |
| 30 | + "This virtual Python environment will give this library its own copy of Python, its own set of tools and libraries, and keeping it isolated from other projects. Before we start, please ensure you have the new version of Python installed locally on your device.\n", |
| 31 | + "\n", |
| 32 | + "1. Open a new terminal and make sure it is pointing to your project folder (you should see the folder path in the prompt)\n", |
| 33 | + "2. To create the virtual environment, run one of the commands below: \n", |
| 34 | + " ```bash \n", |
| 35 | + " # Mac/Linx\n", |
| 36 | + " python3 -m venv .venv\n", |
| 37 | + " # Windows\n", |
| 38 | + " python -m venv .venv\n", |
| 39 | + " ```\n", |
| 40 | + " This will create the .venv folder in your project. Double check that you can see this folder in the file explorer.\n", |
| 41 | + "3. Now we will activate the virtual environment:\n", |
| 42 | + " ```bash\n", |
| 43 | + " # Mac/Linx\n", |
| 44 | + " source .venv/bin/activate\n", |
| 45 | + " # Windows (Command Prompt)\n", |
| 46 | + " .venv\\Scripts\\activate.bat\n", |
| 47 | + " # Windows (PowerShell)\n", |
| 48 | + " .venv\\Scripts\\Activate.ps1\n", |
| 49 | + " ```\n", |
| 50 | + " You should now see `(.venv)` appear at the start of the terminal prompt. This means it's active!\n", |
| 51 | + "4. Instal ipykernel. This is what allows Jupyter to see your virtual environment as a kernel. With the `.venv` active run:\n", |
| 52 | + " ```bash\n", |
| 53 | + " pip install ipykernel\n", |
| 54 | + " ```\n", |
| 55 | + " Then register it: \n", |
| 56 | + " ```bash\n", |
| 57 | + " # Mac/Linx\n", |
| 58 | + " python3 -m ipykernel install --user --name=.venv --display-name \"Python (.venv)\"\n", |
| 59 | + " # Windows\n", |
| 60 | + " python -m ipykernel install --user --name=.venv --display-name \"Python (.venv)\"\n", |
| 61 | + " ```\n", |
| 62 | + "5. Now you should be able to select this virtual environment as a kernel. Click on the **\"Select Kernel\"** in the top right. Chose Python environments and select Python(.venv), the one you just created! If it doesn't show up right away, try reloading your window.\n", |
| 63 | + "6. Open the command palette (Crl+Shift+P or Cmd+Shift+P) and find **\"Python:Select Interpreter\"**. Chose the .venv option to tell VS code to always use this interpreter going forward.\n", |
| 64 | + "\n", |
| 65 | + "Now we have ensured that we can use and run Python in there Jupyter notebooks. Time to get down to business in Numerics!\n", |
| 66 | + "\n", |
27 | 67 | "## What is Numerics?\n", |
28 | 68 | "Numerics is a comprehensive .NET library for numerical computing and statistical analysis, developed by the U.S. Army Corps of Engineers Risk Management Center [[1]](#1). It includes:\n", |
29 | 69 | "\n", |
|
0 commit comments