Python in Excel is available in Excel for Windows using the Beta Channel. Currently, the feature is not available on other platforms.
If you encounter any issues with Python in Excel, please report them by selecting Help > Feedback in Excel.
New to Python in Excel? Start with Introduction to Python in Excel and Getting started with Python in Excel.
Python runs on the Microsoft Cloud
Python in Excel runs the Python code used by Excel in a secure container on the Microsoft Cloud with enterprise-level security as a compliant Microsoft 365 connected experience.
Python code runs on hypervisor isolated containers built on Azure Container Instances.
The container has Python and a curated set of secured libraries provided by Anaconda.
The environment uses the Anaconda Distribution for Python, which contains source-built Python and libraries, provided directly from Anaconda.
The Python code does not have access to your computer, devices, or account.
The Python code does not have network access.
The Python code does not have access to a user token.
The Python code can access data through the references via the built-in xl() function as part of a Python formula. This means that Python formulas have access to read cell values within the workbook, based on the cell reference, or values from external data sources, through the Power Query connection name.
Python code returns output to your workbooks through the =PY() Excel function, which displays the result of the Python code in the cell where the function is entered. Python functions cannot return other object types like macros, VBA code, or other formulas.
The Python code doesn’t have access to other properties in the workbook, such as formulas, charts, PivotTables, macros, or VBA code.
How does Python in Excel handle workbooks from the internet or untrusted sources?
Python in Excel follows the same security policies as Excel when it comes to opening workbooks from the internet or untrusted sources.
If you open a workbook that contains Python code from the internet, Excel Protected View won’t run Python formulas in the workbook. If a workbook is opened with Microsoft Defender Application Guard, Python formulas don’t run by default.
In addition, Python in Excel runs the Python formulas in the untrusted workbook within its own dedicated hypervisor isolated container, helping prevent potential interaction or interference with other Python code running from other open workbooks.
How often does Microsoft update the containers that the Python code runs on?
Python in Excel uses containers to run Python code on Azure. Containers are isolated and secure environments that can run applications and services without affecting the rest of the system. To help ensure the security and reliability of the containers, regular updates and patches are applied to them.
Python and the libraries are updated in the following ways to help keep your data secure and your numerical results consistent.
Patches are applied to the underlying operating system that the Azure Container Instance runs on. This helps ensure that the container is protected from vulnerabilities and exploits that may affect your data. This is done automatically with no input required from you.
Once Python in Excel becomes generally available, periodic updates of the Python environment will be released, with Python and the libraries provided by Anaconda. These versions include the latest security fixes and enhancements from the Python and Anaconda communities. These releases will be announced through blog posts and documentation. This will be done automatically with no setup required, and Microsoft will default to the latest environment. Existing workbooks will still calculate against the version of the environments the workbook was created on, and users will be prompted to upgrade if there is a newer version. This approach helps ensure that your numerical results stay consistent and allows you and your organization to stay up to date.
How does Microsoft respect your data and privacy?
Your privacy is important to Microsoft. See the Microsoft privacy statement for more details.
To review the data protection policies of Microsoft 365 connected experiences, see Connected experiences in Microsoft 365.
Update the registry to toggle security warnings for Python in Excel
The following commands show how to update the registry to change security warning settings for Python in Excel. You can run the commands from an elevated command prompt on a Windows device.
Use this command to disable all security warnings. This is the default setting for Python in Excel.
reg add HKCU\software\policies\microsoft\office\16.0\excel\security /v PythonFunctionWarnings /t REG_DWORD /d 0 /f
Use this command to enable a security prompt when opening a workbook that contains a Python formula. It enables a Security Warning notice in the Excel business bar. See the following screenshot for an example.
reg add HKCU\software\policies\microsoft\office\16.0\excel\security /v PythonFunctionWarnings /t REG_DWORD /d 1 /f
Use this command to disable all Python functions from running. Python functions will return the error #BLOCKED!.
reg add HKCU\software\policies\microsoft\office\16.0\excel\security /v PythonFunctionWarnings /t REG_DWORD /d 2 /f
Microsoft will continue to monitor and adjust Python in Excel to keep you and your data safe. This may involve future changes to the user experience and registry settings.
Thanks for reading, you can also learn more about IT knowledge at our AddOn IT Library