Question #241   Submitted by Answiki on 12/06/2020 at 08:00:19 PM UTC

How to install package in jupyter notebook?

Answer   Submitted by Answiki on 12/06/2020 at 08:17:00 PM UTC

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

3 events in history
Answer by Answiki on 12/06/2020 at 08:17:00 PM

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

Answer by Answiki on 12/06/2020 at 08:10:04 PM

In Jupyter Notebook, the exclamation mark ! is used to run a shell command from the notebook:



Question by Answiki 12/06/2020 at 08:00:19 PM
How to install package in jupyter notebook?
# ID Query URL Count

Icons proudly provided by Friconix.