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!!

🌐
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.
🌐
Medium
medium.com › @marc.bolle › learn-these-15-magic-commands-in-jupyter-notebook-to-save-time-a864ca9b15c7
Learn These 15 Magic Commands in Jupyter Notebook to Save Time | by Marc Bolle | Medium
May 19, 2023 - Here’s one of the commands I find the most useful. If you accidentally delete a cell and its output, you can use the magic command %history to display all the previous commands you’ve executed in your current Jupyter Notebook session.
🌐
KDnuggets
kdnuggets.com › jupyter-notebook-magic-methods-cheat-sheet
Jupyter Notebook Magic Methods Cheat Sheet - KDnuggets
February 15, 2024 - Magic methods are special commands that provide additional functionality beyond standard Python syntax. There are two types of magic methods in Jupyter notebook: line magics and cell magics.
🌐
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.
Find elsewhere
🌐
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.
🌐
Jupyter Community Forum
discourse.jupyter.org › notebook
Run magic command not passing variable - Notebook - Jupyter Community Forum
October 4, 2021 - Hello everyone, I have many Jupyter notebooks with different ipywidgets programs in them. Now, I wanna make a “Master notebook” and use the %run magic command to run the other scripts in the cells of my master notebook. …
🌐
Medium
medium.com › @techlatest.net › unleashing-the-power-of-magic-commands-in-jupyter-notebook-ai-and-ai-explained-047e251eb52a
Unleashing the Power of Magic Commands in Jupyter Notebook: %ai and %%ai Explained
November 29, 2023 - Jupyter Notebook provides magic commands, which are shortcuts and extra functionalities that extend the capabilities of the notebook beyond pure Python code. There are two types of magic commands: line magics and cell magics.
🌐
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
🌐
Note.nkmk.me
note.nkmk.me › home › jupyter notebook
Check the List of Magic Commands in Jupyter Notebook and IPython | note.nkmk.me
March 30, 2023 - You can check the list of magic commands available in Jupyter Notebook (IPython Notebook) with %lsmagic. ALthough official documents about magic commands are available online, some commands might be u ...
🌐
Scribd
scribd.com › document › 706856250 › Jupyter-Notebook-Magic-Methods-Cheat-Sheet-KDnuggets
Jupyter Magic Commands Guide | PDF
There are two types of magic methods: ... include %lsmagic to list magic commands, %who to show defined variables, %run to execute external Python files, and %precision to set floating point number precision for output....
🌐
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 ...
🌐
Medium
medium.datadriveninvestor.com › the-ultimate-guide-to-using-ipython-jupyter-magic-commands-for-enhanced-notebooks-4b9eeb689566
The Ultimate Guide to Using IPython Jupyter Magic Commands for Enhanced Notebooks
February 24, 2024 - These are called IPython Jupyter Magic Commands, and they are special commands that start with a % or %% sign and can perform various tasks, such as timing your code, debugging, running shell commands, and more.