Arthur Camberlein >> SEO & Data articles >> When to use !pip, %pip or !uv in Python?

When to use !pip, %pip or !uv in Python?

Written by Arthur Camberlein | Published on & updated on

For Jupyter Notebooks, the modern approach is: %pip install such as %pip install ShopifyAPI.

%pip is a magic command

The `%pip is called a "magic command" and it is preferred over `!pip` because it ensures the package is installed in the same Python environment that the kernel is using.

But what does this change?

You could be wondering what would be the impact? This avoids common issues where !pip installs to a different Python environment. Especially on Notebooks.

Best practice

For even better practice, if you're using newer Python package managers:

%pip install --upgrade ShopifyAPI

Or if you're using uv (which is faster):

!uv add ShopifyAPI
Retour au blog

Learn more with the article FAQ

When to use !pip, %pip or !uv in Python? - FAQs

What is !pip?

!pip is a command-line prefix used in interactive Python environments like Jupyter notebooks or IPython shells to execute shell commands directly. Prefer %pip as indicated in this article.

What is %pip?

pip as the standard package installer and the % introduces the magic command. You also might have heard about !pip, but the %pip offers better integration.

What is !uv?

uv is a package installer and project management command. It aims to replace pip, pyenv, poetry or even pipx. When you use !uv, you are using uv in a Notebook environment.

Related Articles