Skip to content

Instantly share code, notes, and snippets.

@jtpio
Last active May 5, 2019 13:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jtpio/a516ee4b924c650ec4489573efe586f2 to your computer and use it in GitHub Desktop.
Save jtpio/a516ee4b924c650ec4489573efe586f2 to your computer and use it in GitHub Desktop.
Using the latest CPython in a Jupyter Notebook
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Using the latest CPython in a Jupyter Notebook\n",
"\n",
"## Jeremy Tuloup - [github.com/jtpio](https://github.com/jtpio)"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'3.7.2 (default, Dec 29 2018, 06:19:36) \\n[GCC 7.3.0]'"
]
},
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import sys\n",
"sys.version"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 1. Clone the cpython repo\n",
"\n",
"#### [https://github.com/python/cpython](https://github.com/python/cpython)\n",
"\n",
"```bash\n",
"git clone https://github.com/python/cpython\n",
"\n",
"cd cpython\n",
"```"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 2. Create a new conda environment\n",
"\n",
"```bash\n",
"conda create -n cpython\n",
"conda activate cpython\n",
"```"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 3. Check the conda environment variables\n",
"\n",
"```bash\n",
"env | grep CONDA\n",
"echo ${CONDA_PREFIX}\n",
"```"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 4. Build\n",
"\n",
"```bash\n",
"./configure --prefix ${CONDA_PREFIX}\n",
"make && make install\n",
"```"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 5. Add a new Jupyter kernelspec\n",
"\n",
"```bash\n",
"python3 -m pip install ipykernel\n",
"python3 -m ipykernel install --user \\\n",
" --name cpython \\\n",
" --display-name \"CPython\"\n",
"```"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 6. Use the new kernel\n",
"\n",
"![kernel](./kernel.png)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 7. Test"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'3.8.0a3+ (heads/master:99fcc616d4, May 4 2019, 18:58:02) \\n[GCC 7.4.0]'"
]
},
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import sys\n",
"sys.version"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Thanks!"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.2"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment