Magic commands are a feature of iPython, which is a superset of python. They allow for shell-style commands, and are preceded by a %. They can be programmed to do anything, presumably your set-up has an install command. You can also do shell commands directly using !. For instance, !echo hi. Answer from Deleted User on reddit.com
IPython
ipython.readthedocs.io › en › 9.2.0 › interactive › magics.html
Built-in magic commands — IPython 9.2.0 documentation
The filename argument should be either a pure Python script (with extension .py), or a file with custom IPython syntax (such as magics). If the latter, the file can be either a script with .ipy extension, or a Jupyter notebook with .ipynb extension. When running a Jupyter notebook, the output from print statements and other displayed objects will appear in the terminal (even matplotlib figures will open, if a terminal-compliant backend is being used). Note that, at the system command line, the jupyter run command offers similar functionality for executing notebooks (albeit currently with some differences in supported options).
Reddit
reddit.com › r/learnpython › what exactly are magic commands?
r/learnpython on Reddit: What exactly are magic commands?
January 29, 2024 -
Hello all, just had a quick question on what exactly is a magic command?
I am working in a 3P environment where I have no control over libraries/modules installed, but help desk (for a lack of a better term) let me know that I can use the magic command as a "work around"? I.e. %install xlsxwriter?
What is the point of this, and what does it do exactly? My uneducated guess is that it installs a module each time you run the script?
Any help would be greatly appreciated. Thank you all!!
Top answer 1 of 8
17
Magic commands are a feature of iPython, which is a superset of python. They allow for shell-style commands, and are preceded by a %. They can be programmed to do anything, presumably your set-up has an install command. You can also do shell commands directly using !. For instance, !echo hi.
2 of 8
7
There are two types of magics: line magic (% prefix) and cell magic (%% prefix).
Videos
07:33
Magic commands in Jupyter and IPython - YouTube
03:22
Must know #Magic Commands for Jupyter Notebook. - YouTube
06:24
How to Use Jupyter Magic Commands to Improve the Notebook Experience ...
26:52
Magic Commands in Python: Understanding %% Commands in Jupyter ...
06:20
#4 IPython %magic Commands - YouTube
15:42
Magic Commands of Jupyter Notebook - YouTube
IPython
ipython.readthedocs.io › en › stable › interactive › magics.html
Built-in magic commands — IPython 9.13.0 documentation
February 2, 2026 - The filename argument should be either a pure Python script (with extension .py), or a file with custom IPython syntax (such as magics). If the latter, the file can be either a script with .ipy extension, or a Jupyter notebook with .ipynb extension. When running a Jupyter notebook, the output from print statements and other displayed objects will appear in the terminal (even matplotlib figures will open, if a terminal-compliant backend is being used). Note that, at the system command line, the jupyter run command offers similar functionality for executing notebooks (albeit currently with some differences in supported options).
Codecademy
codecademy.com › docs › data science › jupyter magic commands
Data Science | Jupyter Magic Commands | Codecademy
February 26, 2025 - These commands allow users to perform file operations, timing, debugging, and system interactions without leaving the notebook environment. ... Line magics (%): Operate on a single line of code.
GeeksforGeeks
geeksforgeeks.org › python › useful-ipython-magic-commands
Useful IPython magic commands - GeeksforGeeks
July 23, 2025 - Jupyter has support for over 40 different programming languages and Python is one of them. Magic commands generally known as magic functions are special commands in IPython that provide special functionalities to users like modifying the behavior of a code cell explicitly, simplifying common tasks like timing code execution, profiling, etc.
Dagworks
blog.dagworks.io › p › using-ipython-jupyter-magic-commands
Using IPython Jupyter Magic commands to improve the notebook experience
February 14, 2024 - Many are available by default, including %timeit to measure the execution time of the cell and �sh to execute shell commands, and others are provided by extensions such as %sql to write SQL queries directly in a cell of your notebook. In this post, we’ll show how your team can turn any utility function(s) into reusable IPython Jupyter magics for a better notebook experience.
JupyterLab
coderefinery.github.io › jupyter › extra-features
Shell commands, magics and widgets — Jupyter notebooks documentation
Line magics: commands prepended by one % character and whose arguments only extend to the end of the current line. Cell magics: use two percent characters as a marker (%%), receive as argument the whole cell (must be used as the first line in a cell)
Psu
courses.ems.psu.edu › geog489 › node › 2205
3.6.3 Magic commands | GEOG 489: Advanced Python Programming for GIS
As a first example, you can use the magic command %lsmagic to list the available magic commands (Figure 3.11).
Cloudera
docs.cloudera.com › cdsw › 1.10.5 › workbench › topics › cdsw-jupyter.html
Jupyter Magic Commands
Cloudera Data Science Workbench's Scala and Python kernels are based on Jupyter kernels. Jupyter kernels support varying magic commands that extend the core language with useful shortcuts. This section details the magic commands (magics) supported by Cloudera Data Science Workbench.
Stata
stata.com › python › pystata19 › notebook › Magic Commands0.html
Magic commands — pystata documentation
Note that the magic commands can only be used in an IPython environment, such as Jupyter Notebook. They will not work in a non-IPython environment, like the Windows Command Prompt, the macOS terminal, the Unix terminal, a Python script file, etc. However, you can use the API functions defined ...
Kaggle
kaggle.com › code › rabbani › using-magic-commands-with-jupyter-notebook
Using Magic Commands with Jupyter Notebook
Checking your browser before accessing www.kaggle.com · Click here if you are not automatically redirected after 5 seconds
Jupyter Community Forum
discourse.jupyter.org › notebook
Top Magic Commands in the Jupyter Notebook - Notebook - Jupyter Community Forum
January 29, 2023 - Jupyter Community Forum · Top Magic Commands in the Jupyter Notebook · Notebook · how-to · Sigmund · January 29, 2023, 7:36pm · Deepsim Blog – 29 Jan 23 · Top Magic Commands in the Jupyter Notebook - Deepsim Blog · Using magic commands in the Jupyter notebook can greatly increase ...