I want to be able to run both Python 3.8 (currrent version) and Python 3.7 in my Jupyter Notebook. I understand creating different IPython kernels from virtual environments is the way.
So I downloaded Python 3.7 and locally installed it in my home directory. Used this python binary file to create a virtual environment by
> virtualenv -p ~/Python3.7/bin/python3 py37
> source py37/bin/activate
This works perfectly and gives ‘Python 3.7’ correctly on checking with python --version
and sys.version
.
Then for creating IPython kernel,
(py37) > ipython kernel install --user --name py37 --display-name "Python 3.7"
(py37) > jupyter notebook
This also runs without error and the kernel can be confirmed to be added in the Notebook. However it does not run Python 3.7 like the virtual environment, but Python 3.8 like the default kernel. (confirmed with sys.version
)
I checked ~/.local/share/jupyter/kernels/py37/kernel.json
and saw its contents as
{
"argv": [
"/usr/bin/python3",
"-m",
"ipykernel_launcher",
"-f",
"{connection_file}"
],
"display_name": "Python 3.7",
"language": "python"
So naturally I tried editing the /usr/bin/python3
to point to my Python 3.7 binary file path that is ~/Python3.7/bin/python3
, but then even the kernel doesn’t work properly in the notebook.
What can I possibly do?
NB: I use Arch Linux, so I installed jupyter, virtualenv, … through pacman not pip as its recommended in Arch.