0

I have a written in python an Azure function that itterates over the defined names in an excel sheet. I'm using Python 3.9 and Openpyxl 3.1.0. When I run this function localy it works al fine. But when I port this function to Azure I get the error 'DefinedNameDict' object has no attribute 'definedName'"

The code that I use is

for dn in wb.defined_names.definedName:
    if dn.name[:3] == 'FD_':

I have already tried to upgrade to openpyxl 3.1.1 but this gives another error that is already mentioned in stackoverflow

AttributeError: 'ReadOnlyWorksheet' object has no attribute 'defined_names.

I have downgraded to openpyxl 3.1.0 but I got still the same error

  • Could you provide full code snippet to check the cause of the issue in Azure Cloud? –  Mar 03 '23 at 14:01
  • I tried to insert the whole code snippet but it is to large to enter in this box – Gerrit Seigers Mar 03 '23 at 14:13
  • Insert your code in the GitHub Repository and provide its URL. –  Mar 03 '23 at 14:17
  • Have found the sollution. I have downgraded to openpyxl 3.0.0 – Gerrit Seigers Mar 03 '23 at 14:55
  • Glad to hear that. Could you help me with the versions you have tried and where they are working good (both locally and Azure cloud) so that I can raise the issue with the latest version in official forums. –  Mar 03 '23 at 14:58
  • As I can see after the version `3.0.0`, there are more than 5 versions released with the `3.0.x` where x = 1 to 10. [openpyxl official site](https://pypi.org/project/openpyxl/#history) Are all these versions not worked with your requirement? –  Mar 03 '23 at 15:03
  • I have put the following statement in te requirements.txt file openpyxl>=3.0.7,<3.1.0. The version that was installed in the Azure Devops was openpyxl-3.0.10-py2.py3-none-any.whl. – Gerrit Seigers Mar 03 '23 at 16:48

1 Answers1

0

Glad @GerritSeigers that you have resolved the issue with the following steps:

If the requirements.txt file contains the package versions like openpyxl>=3.0.7,<3.1.0, it works successfully in local environment based on the available version of that package.

Similarly, the version of the Python Package openpyxl is 3.0.10-py2.py3-none-any.whl installed on the Azure DevOps Project so that the Azure Functions Project works with the current installed package version and that compatible version should be using in the code.

Refer to the SO #75392950 for more information on how does the python packages version will affect the Azure Functions with respective to Azure DevOps and requirements.txt file.