👋 Hello! I'm Alphonsio the robot. Ask me a question, I'll try to answer.
how to install package in jupyter notebook
In Jupyter Notebook, the exclamation mark !
is used to run a shell command from the notebook. The following examples install numpy:
# Install with pip
!pip install numpy
# Install with conda
!conda install --yes numpy
The previous should work on most systems, however, it may fail if the default system command is not the same as your current Jupyter kernel. A more portable option is to use Jupyter kernel path with {sys.executable}
or {sys.prefix}
:
# Import sys to get sys.executable
import sys
# Install with pip
!{sys.executable} -m pip install numpy
# Install with conda
!conda install --yes --prefix {sys.prefix} numpy