Last active
April 22, 2025 15:04
-
-
Save kargaranamir/e0b7910fed0a3189563d9254c7a2c439 to your computer and use it in GitHub Desktop.
Use different version of Python in Google Colab (Python 3.9 or Python 3.10)
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
{ | |
"nbformat": 4, | |
"nbformat_minor": 0, | |
"metadata": { | |
"colab": { | |
"name": "Google colab python3.9 or python3.10.ipynb", | |
"provenance": [] | |
}, | |
"kernelspec": { | |
"name": "python3", | |
"display_name": "Python 3" | |
}, | |
"language_info": { | |
"name": "python" | |
} | |
}, | |
"cells": [ | |
{ | |
"cell_type": "markdown", | |
"source": [ | |
"## Use different version of Python in Google Colab (Python 3.9 or Python 3.10)" | |
], | |
"metadata": { | |
"id": "UtfrQgGWwIhY" | |
} | |
}, | |
{ | |
"cell_type": "code", | |
"source": [ | |
"## for python 3.10, run this cell\n", | |
"!wget -O mini.sh https://repo.anaconda.com/miniconda/Miniconda3-py310_22.11.1-1-Linux-x86_64.sh\n", | |
"!chmod +x mini.sh\n", | |
"!bash ./mini.sh -b -f -p /usr/local\n", | |
"!conda install -q -y jupyter\n", | |
"!conda install -q -y google-colab -c conda-forge\n", | |
"!python -m ipykernel install --name \"py310\" --user" | |
], | |
"metadata": { | |
"id": "EBcJMsi6viLZ" | |
}, | |
"execution_count": null, | |
"outputs": [] | |
}, | |
{ | |
"cell_type": "code", | |
"source": [ | |
"## for python 3.9 run this cell\n", | |
"!wget -O mini.sh https://repo.anaconda.com/miniconda/Miniconda3-py39_4.9.2-Linux-x86_64.sh\n", | |
"!chmod +x mini.sh\n", | |
"!bash ./mini.sh -b -f -p /usr/local\n", | |
"!conda install -q -y jupyter\n", | |
"!conda install -q -y google-colab -c conda-forge\n", | |
"!python -m ipykernel install --name \"py39\" --user" | |
], | |
"metadata": { | |
"id": "2WxCQgO5SHOb" | |
}, | |
"execution_count": null, | |
"outputs": [] | |
}, | |
{ | |
"cell_type": "code", | |
"source": [ | |
"! python3 --version" | |
], | |
"metadata": { | |
"colab": { | |
"base_uri": "https://localhost:8080/" | |
}, | |
"id": "tLDriuO8pb7c", | |
"outputId": "815f1345-002b-4af7-9b51-9f2ee1df1118" | |
}, | |
"execution_count": 2, | |
"outputs": [ | |
{ | |
"output_type": "stream", | |
"name": "stdout", | |
"text": [ | |
"Python 3.10.8\n" | |
] | |
} | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"source": [ | |
"!python3 -m pip install numpy" | |
], | |
"metadata": { | |
"id": "uoQheE-PqY5x" | |
}, | |
"execution_count": null, | |
"outputs": [] | |
}, | |
{ | |
"cell_type": "code", | |
"source": [ | |
"%%writefile code.py\n", | |
"\n", | |
"import numpy as np\n", | |
"print(np.arange(15).reshape(3, 5))" | |
], | |
"metadata": { | |
"id": "HbDerwdZSbmO" | |
}, | |
"execution_count": null, | |
"outputs": [] | |
}, | |
{ | |
"cell_type": "code", | |
"source": [ | |
"! python3 code.py" | |
], | |
"metadata": { | |
"id": "MuwKOO72pXQW" | |
}, | |
"execution_count": null, | |
"outputs": [] | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Link to google colab: https://colab.research.google.com/gist/kargaranamir/e0b7910fed0a3189563d9254c7a2c439/Google_colab_python3_9_or_python3_10.ipynb