With more than one virtual environments, there is an additional setup if one wants to use Jupyter Notebook. In order to check whether Jupyter Notebook is using the same python executable, run the following scripts in Jupyter Notebook:
import sys sys.executable
I explicitly write
python3 but if you are using
python may be enough. If you see different outputs for the above scripts, then there is a problem.
From now on, I followed Kernels for different environments in IPython Documentation. First, I activated a virtual environment and installed ipykernel:
source (path to a folder)/bin/activate (name) python3 -m ipykernel install --user --name name --display-name "display name"
It seems that Jupyter uses
name internally. I did not try yet without
name when I activated a virtual environment. And
display name is what we are seeing when we select
New in Jupyter notebook, as shown below.
I have display names “TensorFlow” and “DataScienceBowl” in addition to “Python 3”.
Once a new notebook is created, try the scripts shown at the top to be sure that the correct python executable is running. We can switch the python executable through the
It seems that it may be possible to run a python executable in a different environment within a notebook. I would check this later.