This Function Doesn't Perform Detection, It Merely Reads the Result From a Previous Call to
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Troubleshoot Python errors in Azure Functions
Following is a list of troubleshooting guides for common problems in Python functions:
- ModuleNotFoundError and ImportError
- Cannot import 'cygrpc'
- Python exited with lawmaking 137
- Python exited with code 139
Troubleshoot ModuleNotFoundError
This section helps you troubleshoot module-related errors in your Python office app. These errors typically issue in the following Azure Functions fault message:
Exception: ModuleNotFoundError: No module named 'module_name'.
This error occurs when a Python function app fails to load a Python module. The root cause for this error is 1 of the following issues:
- The package can't be found
- The package isn't resolved with proper Linux bike
- The bundle is incompatible with the Python interpreter version
- The package conflicts with other packages
- The bundle just supports Windows or macOS platforms
View project files
To place the actual crusade of your event, you lot need to get the Python project files that run on your function app. If you don't have the project files on your local computer, you tin get them in i of the post-obit ways:
- If the function app has
WEBSITE_RUN_FROM_PACKAGEapp setting and its value is a URL, download the file by re-create and paste the URL into your browser. - If the function app has
WEBSITE_RUN_FROM_PACKAGEand it is set toone, navigate tohttps://<app-name>.scm.azurewebsites.cyberspace/api/vfs/data/SitePackagesand download the file from the latesthrefURL. - If the function app doesn't accept the app setting mentioned above, navigate to
https://<app-proper noun>.scm.azurewebsites.net/api/settingsand find the URL underSCM_RUN_FROM_PACKAGE. Download the file by copy and paste the URL into your browser. - If none of these works for you, navigate to
https://<app-name>.scm.azurewebsites.net/DebugConsoleand reveal the content under/home/site/wwwroot.
The residue of this commodity helps y'all troubleshoot potential causes of this mistake past inspecting your part app'due south content, identifying the root crusade, and resolving the specific result.
Diagnose ModuleNotFoundError
This section details potential root causes of module-related errors. After yous effigy out which is the likely root crusade, you tin can go to the related mitigation.
The package tin't be found
Browse to .python_packages/lib/python3.half-dozen/site-packages/<package-name> or .python_packages/lib/site-packages/<parcel-proper name>. If the file path doesn't be, this missing path is likely the root crusade.
Using third-party or outdated tools during deployment may cause this issue.
See Enable remote build or Build native dependencies for mitigation.
The parcel isn't resolved with proper Linux wheel
Become to .python_packages/lib/python3.6/site-packages/<package-name>-<version>-dist-info or .python_packages/lib/site-packages/<parcel-name>-<version>-dist-info. Use your favorite text editor to open the bike file and cheque the Tag: section. If the value of the tag doesn't incorporate linux, this could be the issue.
Python functions run just on Linux in Azure: Functions runtime v2.x runs on Debian Stretch and the v3.x runtime on Debian Buster. The artifact is expected to incorporate the correct Linux binaries. Using --build local flag in Core Tools, third-political party, or outdated tools may cause older binaries to be used.
See Enable remote build or Build native dependencies for mitigation.
The packet is incompatible with the Python interpreter version
Go to .python_packages/lib/python3.6/site-packages/<bundle-name>-<version>-dist-info or .python_packages/lib/site-packages/<parcel-proper name>-<version>-dist-info. Using a text editor, open the METADATA file and bank check the Classifiers: section. If the section doesn't contains Python :: three, Python :: 3.six, Python :: three.seven, or Python :: 3.8, this ways the packet version is either besides former, or most likely, the package is already out of maintenance.
You can bank check the Python version of your function app from the Azure portal. Navigate to your part app, cull Resources explorer, and select Go.
After the explorer loads, search for LinuxFxVersion, which shows the Python version.
See Update your packet to the latest version or Replace the package with equivalents for mitigation.
The bundle conflicts with other packages
If you have verified that the package is resolved correctly with the proper Linux wheels, in that location may be a conflict with other packages. In certain packages, the PyPi documentations may clarify the incompatible modules. For case in azure 4.0.0, there'south a statement equally follows:
This packet isn't uniform with azure-storage. If you installed azure-storage, or if yous installed azure 1.x/2.x and didn't uninstall azure-storage, yous must uninstall azure-storage beginning.
You can find the documentation for your package version in https://pypi.org/project/<packet-proper name>/<parcel-version>.
See Update your package to the latest version or Replace the parcel with equivalents for mitigation.
The parcel only supports Windows or macOS platforms
Open the requirements.txt with a text editor and cheque the package in https://pypi.org/projection/<package-name>. Some packages just run on Windows or macOS platforms. For example, pywin32 but runs on Windows.
The Module Non Found error may not occur when you're using Windows or macOS for local development. However, the bundle fails to import on Azure Functions, which uses Linux at runtime. This is likely to be caused past using pip freeze to export virtual environment into requirements.txt from your Windows or macOS machine during project initialization.
See Replace the package with equivalents or Handcraft requirements.txt for mitigation.
Mitigate ModuleNotFoundError
The post-obit are potential mitigations for module-related issues. Use the diagnoses above to determine which of these mitigations to try.
Enable remote build
Make certain that remote build is enabled. The way that yous do this depends on your deployment method.
- Visual Studio Code
- Azure Functions Cadre Tools
- Transmission publishing
Brand sure that the latest version of the Azure Functions extension for Visual Studio Code is installed. Verify that .vscode/settings.json exists and it contains the setting "azureFunctions.scmDoBuildDuringDeployment": truthful. If not, please create this file with the azureFunctions.scmDoBuildDuringDeployment setting enabled and redeploy the project.
Build native dependencies
Make sure that the latest version of both docker and Azure Functions Core Tools is installed. Go to your local function projection binder, and use func azure functionapp publish <app-name> --build-native-deps for deployment.
Update your package to the latest version
Browse the latest package version in https://pypi.org/project/<bundle-proper name> and check the Classifiers: section. The parcel should be Bone Independent, or compatible with POSIX or POSIX :: Linux in Operating System. Besides, the Programming Language should contains Python :: three, Python :: 3.6, Python :: 3.7, or Python :: 3.8.
If these are correct, you can update the bundle to the latest version by changing the line <parcel-name>~=<latest-version> in requirements.txt.
Handcraft requirements.txt
Some developers employ pip freeze > requirements.txt to generate the listing of Python packages for their developing environments. Although this convenience should piece of work in well-nigh cases, at that place can be issues in cross-platform deployment scenarios, such equally developing functions locally on Windows or macOS, simply publishing to a function app, which runs on Linux. In this scenario, pip freeze can introduce unexpected operating system-specific dependencies or dependencies for your local evolution environment. These dependencies can break the Python role app when running on Linux.
The all-time practice is to bank check the import statement from each .py file in your project source code and but check-in those modules in requirements.txt file. This guarantees the resolution of packages can exist handled properly on different operating systems.
Supersede the package with equivalents
First, we should accept a expect into the latest version of the package in https://pypi.org/project/<package-proper noun>. Usually, this bundle has their own GitHub page, go to the Problems department on GitHub and search if your issue has been fixed. If so, update the bundle to the latest version.
Sometimes, the package may have been integrated into Python Standard Library (such as pathlib). If then, since we provide a certain Python distribution in Azure Functions (Python 3.vi, Python iii.7, and Python 3.8), the package in your requirements.txt should be removed.
However, if you lot're facing an consequence that information technology has non been fixed and y'all're on a deadline. I encourage yous to practice some enquiry and find a similar package for your project. Normally, the Python customs will provide yous with a wide diversity of similar libraries that you can use.
Troubleshoot cannot import 'cygrpc'
This department helps you troubleshoot 'cygrpc' related errors in your Python function app. These errors typically event in the post-obit Azure Functions error message:
Cannot import name 'cygrpc' from 'grpc._cython'
This error occurs when a Python role app fails to showtime with a proper Python interpreter. The root cause for this fault is one of the following issues:
- The Python interpreter mismatches Os compages
- The Python interpreter is not supported by Azure Functions Python Worker
Diagnose 'cygrpc' reference error
The Python interpreter mismatches OS architecture
This is most probable caused by a 32-bit Python interpreter is installed on your 64-chip operating organisation.
If yous're running on an x64 operating organization, delight ensure your Python three.6, 3.vii, or 3.8 interpreter is also on 64-bit version.
You can check your Python interpreter bitness by the following commands:
On Windows in PowerShell: py -c 'import platform; impress(platform.architecture()[0])'
On Unix-like shell: python3 -c 'import platform; impress(platform.architecture()[0])'
If in that location'due south a mismatch between Python interpreter bitness and operating system compages, delight download a proper Python interpreter from Python Software Foundation.
The Python interpreter is not supported by Azure Functions Python Worker
The Azure Functions Python Worker only supports Python three.half-dozen, 3.vii, and 3.8. Please bank check if your Python interpreter matches our expected version past py --version in Windows or python3 --version in Unix-similar systems. Ensure the render consequence is Python 3.6.ten, Python 3.seven.x, or Python 3.8.x.
If your Python interpreter version does not come across our expectation, please download the Python 3.half-dozen, 3.7, or three.8 interpreter from Python Software Foundation.
Troubleshoot Python Exited With Lawmaking 137
Code 137 errors are typically caused by out-of-memory issues in your Python function app. As a event, y'all go the following Azure Functions error message:
Microsoft.Azure.WebJobs.Script.Workers.WorkerProcessExitException : python exited with code 137
This error occurs when a Python office app is forced to cease by the operating organisation with a SIGKILL signal. This point ordinarily indicates an out-of-memory error in your Python process. The Azure Functions platform has a service limitation which will stop any function apps that exceeded this limit.
Delight visit the tutorial section in retentiveness profiling on Python functions to clarify the memory bottleneck in your function app.
Troubleshoot Python Exited With Code 139
This section helps you troubleshoot segmentation error errors in your Python office app. These errors typically outcome in the post-obit Azure Functions error message:
Microsoft.Azure.WebJobs.Script.Workers.WorkerProcessExitException : python exited with code 139
This error occurs when a Python function app is forced to terminate by the operating system with a SIGSEGV signal. This signal indicates a retention sectionalisation violation which can be caused by unexpectedly reading from or writing into a restricted memory region. In the following sections, we provide a list of common root causes.
A regression from third-party packages
In your office app's requirements.txt, an unpinned package will be upgraded to the latest version in every Azure Functions deployment. Vendors of these packages may introduce regressions in their latest release. To recover from this issue, try commenting out the import statements, disabling the package references, or pinning the package to a previous version in requirements.txt.
Unpickling from a malformed .pkl file
If your office app is using the Python pickel library to load Python object from .pkl file, it is possible that the .pkl contains malformed bytes string, or invalid address reference in it. To recover from this upshot, effort commenting out the pickle.load() function.
Pyodbc connexion collision
If your function app is using the popular ODBC database driver pyodbc, it is possible that multiple connections are opened within a single part app. To avoid this issue, please use the singleton pattern and ensure only ane pyodbc connection is used across the function app.
Next steps
If you're unable to resolve your effect, please report this to the Functions team:
Feedback
Submit and view feedback for
Source: https://docs.microsoft.com/en-us/azure/azure-functions/recover-python-functions
0 Response to "This Function Doesn't Perform Detection, It Merely Reads the Result From a Previous Call to"
Post a Comment