Skip to content

Installing Python packages in Jupyter Notebooks

Don Jayamanne edited this page Nov 15, 2021 · 1 revision

pip install vs python -m pip install

When installing packages using pip, the recommended approach is to use python -m pip install instead of pip install. Refer the Installing Python Modules documentation.

!pip install vs %pip install

Any command prefixed with ! is treated as a shell command in Jupyter cells. Thus !pip install <module> is treated as a simple shell command that translates to pip install <module>. However the recommendation is to use python -m pip install <module>. To get this desired behavior one must use %pip install <module>

%conda install

However when installing packages in Jupyter into a conda environment, use of conda install is preferred over pip install. Hence its highly recommended that one use %conda install in jupyter notebooks when dealing with Conda enviornments.

More information

See here for further details https://jakevdp.github.io/blog/2017/12/05/installing-python-packages-from-jupyter/

Clone this wiki locally