Question #401

How to install package in jupyter notebook?

Answer

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 Alphonsio 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 Alphonsio 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 Alphonsio 12/06/2020 at 08:00:19 PM
How to install package in jupyter notebook?
# ID Query URL Count

Icons proudly provided by Friconix.