Skip to content Skip to sidebar Skip to footer

How Do I Install Python Packages In Jupyter Notebook Running From Wsl2+ubuntu20.04

I am running jupyter notebook from WSL2+Ubuntu20.04. However, the jupyter notebook image does not include many package. For instance, I would like to install pandas and append sys

Solution 1:

You just need to install the package from the terminal, no need to do anything in Jupyter.

To install pandas, type in terminal:

pip install pandas

Now import in jupyter, it will work fine.

Also, no need to use sudo.

Solution 2:

Make sure you are installing packages in the correct environment. From the code trace above, it appears that Pandas is installed in environment serving Jupyter server.

import sys

# upgrade pip and install package
!{sys.executable} -m pip install –upgrade pip && !{sys.executable} -m pip install package 

The above code, makes sure that a package is install in the environment that you are currently in session.

You can open terminal session in Jupyter that will give you assess to shell. I would recommend installing packages there as you would in normal terminal. See Jupyter Documentation for how to access terminal

Post a Comment for "How Do I Install Python Packages In Jupyter Notebook Running From Wsl2+ubuntu20.04"