Getting to know Python in Excel
- By Liam Bastick and Kathryn Newitt
- 2/25/2026
Learning about Python in Excel error codes
New functionality brings new errors. This section describes when and why each Python error occurs and how to avoid errors. You met the #PYTHON! error earlier, so let’s start there. Open the Excel workbook SP Python in Excel Example Starter File Chapter 2.xlsm and select the sheet called Python Syntax Examples.
#PYTHON!
Essentially, the #PYTHON! error occurs when the Python code cannot be compiled. You encountered this error when you used the input Python function (see Figure 2-143).
FIGURE 2.143 Using the input function results in an error.
When the #PYTHON! error occurs, you can click the warning triangle to learn more about the cause (see Figure 2-144).
FIGURE 2.144 You can click the warning triangle to open the Python Error menu, which has options for handling an error.
Let’s explore the list of options in the Python Error menu, beginning with Help on This Error.
Help on This Error
The Help on This Error option opens a Help pane on the right side of the screen (see Figure 2-145).
FIGURE 2.145 The Help pane for dealing with a #PYTHON! error
The Help pane options give further information about possible causes of the error:
External Error: An error occurred in an external calculation service.
Power Query Error (although it really should be Python Interpreter Error): The Python interpreter returned an error when running the Python code.
Python Execution Error: Python in Excel was unable to execute the Python code. You can check the Python formula for errors and try again.
Service Error: Something went wrong with the service. You can try again.
Network Calls Are Unsupported: Python in Excel supports importing data from an Excel worksheet or a Power Query data source. To protect your security, common external data functions in Python, such as pandas.read_csv and pandas.read_excel, are not compatible with Python in Excel. To import external data, use the Get & Transform feature in Excel to access Power Query.
Show Error Message
The Show Error Message option displays more information about the specific error in an error dialog box, as shown in Figure 2-146.
FIGURE 2.146 The Python Error Message dialog gives more information about the cause of a #PYTHON! error.
The message is the same as the one you saw when hovering over the warning triangle when you first entered the Python code in cell F9. You also saw it in the Python Editor. The trace ID can be used to find more information about errors that are difficult to diagnose. It may be recognized by Excel support or in Excel forums. In this case, it is clear from the message that the input request is not supported in Python in Excel.
Show Calculation Steps
The Show Calculation Steps option is designed to help you find the issue in a complex formula. Clicking it opens the Evaluate Formula dialog (see Figure 2-147).
FIGURE 2.147 The Evaluate Formula dialog helps you to locate the line of Python code that triggers the error.
The Evaluate Formula dialog is not particularly useful in this example because there is only one line of Python code. For longer sections of code, though, the Evaluate Formula dialog could help you locate the line of code that triggers the error. If you click Evaluate for the current line of code, the result is #PYTHON!.
Edit in Python Editor
As its name suggests, the Edit in Python Editor option opens the Python Editor, showing information on the currently selected cell (see Figure 2-148).
FIGURE 2.148 The Edit in Python Editor option in the Python Error menu opens the Python Editor.
We will explore error troubleshooting in the Python Editor in Chapter 4.
Ignore Error
The Ignore Error option changes the setting for the cell so that the error is not flagged in Excel. You can select it to remove the icons indicating an error.
Edit in Formula Bar
The Edit in Formula Bar option takes you to the formula bar for the cell.
Error Checking Options
The Error Checking Options item takes you to the Excel Options dialog with the Formulas tab open (see Figure 2-149).
FIGURE 2.149 The Error Checking Options item in the Python Error menu opens the Excel Options dialog.
The Excel Options dialog includes some useful options for working with Python in Excel. The Calculation Options section of the Formulas tab allows you to view and change the workbook calculation settings. You can run Python in Partial or Manual mode with the Python add-on. (See the section “Upgrading to the Python in Excel add-on license,” earlier in this chapter, for more details.) Reset Ignored Errors is a good option if you chose Ignore Error and have changed your mind. (You will learn about more items in the Excel Options dialog as they become pertinent to our discussion.)
#BLOCKED!
#BLOCKED! errors are not unique to Python in Excel. This type of error can be returned when a required resource can’t be accessed. For example, you may encounter it when using the IMAGE function to insert images into cells from a source location.
Earlier in this chapter, we noted that if you are using a Python in Excel license associated with your company account, you cannot use your personal OneDrive account to work with Python in Excel; instead, you need to work on a local drive or in a folder that is associated with the company account. If you try to use Python in Excel in a location not connected to a valid license, you will encounter a #BLOCKED! error. The example in Figure 2-150 shows an attempt to edit a Python formula using a location not associated with a Python license.
FIGURE 2.150 Trying to edit a Python cell when the workbook is not in a location associated with a valid Python in Excel license
Accessing the Excel Value view for this cell causes the #BLOCKED! error to be issued (see Figure 2-151).
FIGURE 2.151 Evaluating a Python cell causes a #BLOCKED! error and a message that the license is not associated with the file location.
Note that some of the cells show #FIELD! instead of #BLOCKED!. These cells contain the Python attributes accessed from the Insert Data menu of the associated Python cell (see Figure 2-152).
FIGURE 2.152 Cells containing the field values associated with a Python cell cannot be recalculated without a valid Python license.
There are other possible causes of the #BLOCKED! error when using Python in Excel. The following sections cover some alternative error messages you might see.
Allow Connection Experience
Python in Excel, like many other features, uses cloud-based services. Some companies have security concerns about using cloud-based services. If yours does, you can turn off connected experiences by going to File > Account > Manage Settings and making the appropriate changes in the Privacy Settings dialog that appears (see Figure 2-153).
FIGURE 2.153 The Privacy Settings dialog allows you to turn off optional connected experiences.
You can click the Learn More link to find out how the Turn on Optional Connected Experiences setting affects your Microsoft Office applications. You cannot calculate Python cells if you switch off this setting.
Compute Resource Error
The Compute Resource Error message is also connected with the use of the Microsoft Cloud. It indicates that a compute resource was recycled and the attempt to automatically retry failed. Microsoft advises that if you get this error message, you should reset the Python runtime. As discussed earlier in the chapter, the reset options are in the Python group on the Formulas tab. You can reset the Python runtime by selecting Reset Runtime in the Python group on the Formulas tab or by using the keyboard shortcut Ctrl+Alt+Shift+F9.
Resetting the Python runtime is often the solution for errors encountered using Python in Excel, since it is the equivalent of “turning it off and back on again.” You may also find that closing and reopening the Excel workbook helps.
Connection Limit Exceeded
The Connection Limit Exceeded message indicates that you have multiple Excel workbooks open that contain Python cells. The solution is to close some of those workbooks.
Daily Quota Exceeded
While there are not currently any published limits associated with using Python in Excel, the Daily Quota Exceeded message indicates that the daily or monthly quota has been exceeded. Check the latest licensing information.
Limit Exceeded
The Limit Exceeded message could indicate that the connection limit or the quota has been exceeded.
Login Failure
If you get the Login Failure message, check your login details.
Not Supported
As noted in the Introduction to this book, Python in Excel is available on several platforms and versions. Using a platform or version where Python in Excel is not available to open an Excel workbook containing Python cells would trigger the Not Supported error message. You might also see one of the alternative messages: Unmet Requirements, Unsupported Environment, or Wrong Account Type.
Python Functions Disabled
If you are in a location with a valid license and you get the Python Functions Disabled error message, contact your administrator.
#BUSY!
The #BUSY! error does not necessarily indicate a problem. It may appear when Python in Excel recalculates a Python cell (see Figure 2-154).
FIGURE 2.154 The #BUSY! message may appear when a formula is calculating.
The #BUSY! error means that Python calculations are running in the Microsoft Cloud. If this error remains on the screen for more than a minute, you can reset the Python runtime. As a reminder, you can reset the Python runtime by selecting Reset Runtime in the Python group on the Formulas tab or by using the keyboard shortcut Ctrl+Alt+Shift+F9.
#CALC!
At the time of writing, Microsoft documentation says that Python in Excel cannot handle volatile functions and gives the Excel function RAND() as an example. RAND() returns a random decimal value from 0 to (but not including) 1 and recalculates every time the worksheet is recalculated. We tested this on the Power Query sheet in the current workbook. You can try it too: Enter the Excel formula =RAND() in cell M10 and then drag it down to cell M19. You now have a range M10:M19 of randomly generated numbers. Now enter the following Python code in cell P10:
df_rand = xl("M10:M19")
Figure 2-155 shows our results, with the Excel value in cell P10. (Remember that because the function returns random numbers, your results will differ from ours.)
FIGURE 2.155 Python in Excel coping with volatile functions
At the time of writing, Python in Excel does not appear to get a #CALC! error when referencing volatile functions.
There are limits to the amount of data that can be calculated. If you are working with a dataset that contains more than 100 MB of data, you may encounter the #CALC! error. When that happens, it is a good idea to reduce the size of the dataset. How you would reduce the dataset size depends on how the dataset is created. For example, if dataset A is created by combining two smaller datasets, B and C, and then the #CALC! error occurs when performing transformations that would reduce the data in dataset A, you should consider whether the data in datasets B and C could be reduced before combining them to make dataset A.
#CONNECT!
The #CONNECT! error indicates an issue with communications with the cloud. In Python in Excel, several error messages may be connected to this error. Let’s look at each of them.
Service Not Available
If a value cannot be retrieved from the service, you may get the Service Not Available message. It means the service has probably timed out. The recommended solution is to reset the Python runtime. As a reminder, you can reset the Python runtime by selecting Reset Runtime in the Python group in the Formulas tab or by using the keyboard shortcut Ctrl+Alt+Shift+F9.
Resource Not Available
The Resource Not Available message also indicates that the value cannot be retrieved, but in this case it is because the compute resource of the service is not available. If this is the first Python value you have tried to refresh in this session, check the license and location. If the license and location are fine or if the error occurs mid-session, then follow the familiar advice to reset the Python runtime: Select Reset Runtime in the Python group in the Formulas tab or use the keyboard shortcut Ctrl+Alt+Shift+F9.
Unable to Upload
The Unable to Upload message usually indicates a temporary issue with the data upload. Try again. If the issue persists, you can (as you may have guessed by now) reset the Python runtime: Select Reset Runtime in the Python group in the Formulas tab or use the keyboard shortcut Ctrl+Alt+Shift+F9.
#SPILL!
If you use dynamic arrays, you will know how to deal with the #SPILL! error. When the formula in a Python cell returns a result, it can be displayed as a Python object or an Excel value. When you display a Python cell as an Excel value and the result is more than one value, it will spill from the Python cell. Any formula that could return multiple values can be called a dynamic array formula. Python formulas expressed as Excel values usually fall into this category.
Let’s return to our earlier example in workbook SP Python in Excel Example.xlsm and locate df_contig_range on the Range Data sheet. When the spill area is empty, the Excel Value view is displayed, as shown in Figure 2-156.
FIGURE 2.156 The Excel value spills from cell O12.
In this example, the border around the range O12:S19 indicates the spill area. If we enter a value into cell Q16 or any other cells in the spill area, we get the #SPILL! error, as shown in Figure 2-157.
FIGURE 2.157 The Excel value cannot spill if a cell in the spill range already contains data.
You may recall that when we created the Python formula in cell O21, we used the cell reference df_contig_range rather than a variable:
df_point_at_contig_range = xl("O12")
Therefore, cell O21 also contains a spill error (see Figure 2-158).
FIGURE 2.158 Referencing a cell with a #SPILL! error triggers another #SPILL! error.
Because the cell is being used, the error is referenced. Note that the error message is slightly different since there is nothing in the spill area for cell O21. Even if we change the view for cell O21 to the Python Object view, the error persists (see Figure 2-159).
FIGURE 2.159 Referencing a cell with a #SPILL! error triggers another #SPILL! error even if the cell is shown in Python Object view.
This is another reason to use a variable and not the cell. If you change cell O21 to use the variable df_contig_range, the error is not triggered (see Figure 2-160).
FIGURE 2.160 Referencing the variable, not the cell that has a #SPILL! error, does not trigger the same error, and the Excel value may be spilled.
So, as you have seen, one way to avoid #SPILL! errors when using Python in Excel is to use variable references rather than cell references. In our example, the offending cell in the spill range for O12 is easy to spot (refer to Figure 2-160). For more complex examples, you can use the error menu to find the problem (see Figure 2-161).
FIGURE 2.161 Clicking the warning arrow next to the #SPILL! error brings up a menu where you can choose the Select Obstructing Cells option.
If you choose Select Obstructing Cells, the offending cell is highlighted, and you are taken to that cell. If more obstructing cells exist, they are all highlighted, and you are taken to the first cell (see Figure 2-162).
FIGURE 2.162 If you choose Select Obstructing Cells, you are taken to the first obstruction.
Once the obstruction is removed, the formula can spill in the Excel Value view. If you are only using the Excel Value view to see the contents easily, you can avoid #SPILL! errors by using the Python Object view and checking the Excel values in the Python Editor instead. This is a good choice for busy worksheets and when dealing with large datasets that could exceed the size of the worksheet.
#TIMEOUT!
The #TIMEOUT! error is often triggered when a Python formula takes longer to calculate than the maximum allotted time. There are two messages that may accompany this error: Formula Timed Out or Python Formula Timed Out. Let’s look at them.
Formula Timed Out
If you get the Formula Timed Out message, try the calculation again. If the problem persists, you know the drill: Reset the Python runtime. As a reminder, you can reset the Python runtime by selecting Reset Runtime in the Python group in the Formulas tab or by using the keyboard shortcut Ctrl+Alt+Shift+F9.
Python Formula Timed Out
Again, the first course of action for the Python Formula Timed Out message is to try the calculation again. If the problem persists, reset the Python runtime: Select Reset Runtime in the Python group in the Formulas tab or use the keyboard shortcut Ctrl+Alt+Shift+F9.
If this message appears frequently, go to File > Options to open the Excel Options dialog. Then, on the Advanced tab, make the selections shown in Figure 2-163 under When Calculating This Workbook.
FIGURE 2.163 The Python Formula Timeout value can be changed in the Excel Options dialog.
By clicking the information icon next to the Python Formula Timeout option, you can get more information about what happens if you change the value, but you won’t get information about what the values can be (see Figure 2-164).
FIGURE 2.164 Changing the Python Formula Timeout value causes the workbook to recalculate.
The Python Formula Timeout setting applies to the workbook selected and cannot be set to less than 30 seconds or more than 7,999 seconds (2 hours and 13 minutes). You should not increase the timeout limit unless you get timeout errors regularly. If you have to set a long timeout limit for multiple workbooks with standard Python in Excel, you might consider getting the Python in Excel add-on for faster computing times.
If you are experiencing #TIMEOUT! errors, your first step should be to reset the Python runtime. Also consider closing and reopening the workbook. If multiple workbooks containing Python calculations are open, you can try closing some of them. You can increase the Python Formula Timeout setting in the Excel Options dialog if issues persist.
Note in Figure 2-163 that there is another option: Automatically Show Python Editor. If this option is selected, the Python Editor will open if an error is triggered or if the print() function is used. It will also open when the cell that contains the error or the print() function is recalculated. Because you are working with examples in this chapter that are sometimes meant to trigger errors to demonstrate a point, you will find that the pane keeps opening. If this annoys you, remove the cell with the error or change the Automatically Show Python Editor setting.
#UNKNOWN!
We briefly mentioned the #UNKNOWN! error earlier in this chapter when discussing the #BLOCKED! error. If you open an Excel workbook containing Python cells in a location not connected to a valid Python in Excel license or use a version of Excel that is not compatible with Python in Excel, you could see the #UNKNOWN! error in a Python cell.
#FIELD!
We also briefly mentioned the #FIELD! error earlier in this chapter when discussing the #BLOCKED! error. If you open an Excel workbook containing Python cells in a location that is not connected to a valid Python in Excel license or use a version of Excel that is not compatible with Python in Excel, you could see this error in a cell that is extracting Python properties from a Python cell. Figure 2-165 shows an associated error message, which indicates that the field that would have been extracted from the Python cell cannot be found.
FIGURE 2.165 If a workbook containing Python data extracted to Excel cells from a Python cell is recalculated and Python in Excel is not available, a #FIELD! error is triggered.

NOTE
TIP