Last active
February 24, 2022 07:41
-
-
Save thehappycheese/efb4a66bef2de23ad60bdd9eb059d0cd to your computer and use it in GitHub Desktop.
Confirm the active python version in your jupyter notebook (the version used by ! terminal cell magics)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"import sys\n", | |
"\n", | |
"print(f\"You are running python {sys.version}.\")\n", | |
"\n", | |
"if not sys.version_info.major >= 3 and sys.version_info.minor >= 9\n", | |
" raise Exception(f\"This notebook requires python 3.9 or later.\")\n", | |
"\n", | |
"print(f\"Your python executable is here: {sys.executable}\")" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"# check the version of python that the terminal is talking to: Should match the version number above\n", | |
"!Powershell Write-Host \"your terminal is configured to call the following python version\"\n", | |
"!Powershell python --version\n", | |
"\n", | |
"!Powershell Write-Host \"Your python installation is here\"\n", | |
"!Powershell (where.exe python).Split([Environment]::NewLine)[0]\n", | |
"!Powershell Write-Host \"And your packages are installed in these locations\"\n", | |
"!python -m site" | |
] | |
} | |
], | |
"metadata": { | |
"language_info": { | |
"name": "python" | |
}, | |
"orig_nbformat": 4 | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 2 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment