Search code examples
pythonjupyter-notebook

ModuleNotFoundError on virtual env Jupyter lab


I have created a virtual env and installed Jupyter notebood and jupyter lab

after import pandas I get ModuleNotFoundError: No module named 'pandas'

doing the same operation with jupyter notebook does not give me an error, which run in the same venv
I installed pandas into the venv, but got the same error
importing the native python modules works fine
inserting !pip install pandas in an empty cell above returns

Requirement already satisfied: pandas in /home/curwin/jupyterlab/venv/lib/python3.8/site-packages (1.1.3)
Requirement already satisfied: pytz>=2017.2 in /home/curwin/jupyterlab/venv/lib/python3.8/site-packages (from pandas) (2020.1)
Requirement already satisfied: python-dateutil>=2.7.3 in /home/curwin/jupyterlab/venv/lib/python3.8/site-packages (from pandas) (2.8.1)
Requirement already satisfied: numpy>=1.15.4 in /home/curwin/jupyterlab/venv/lib/python3.8/site-packages (from pandas) (1.19.2)
Requirement already satisfied: six>=1.5 in /home/curwin/jupyterlab/venv/lib/python3.8/site-packages (from python-dateutil>=2.7.3->pandas) (1.14.0)

Solution

  • I have install a kernel inside the venv with

    ipython kernel install --user --name=.venv
    

    and running notebooks from this kernel solved the problem