Skip to content

Instantly share code, notes, and snippets.

@thehappycheese
Last active February 24, 2022 07:41
Show Gist options
  • Save thehappycheese/efb4a66bef2de23ad60bdd9eb059d0cd to your computer and use it in GitHub Desktop.
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)
Display the source blob
Display the rendered blob
Raw
{
"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