Distro module error on Azure runbook

Arvid0 10 Reputation points
2023-12-02T14:24:42.9433333+00:00

I'm starting out with Azure Automation runbooks, because I would like to schedule some python scripts, which will use openAI GPT via the official openai Python package. I have this script working locally.

After figuring out I needed to use the preview 3.10 version of Python in my runbook (I couldn't get the distro package working otherwise), and installed all dependencies manually on my Automation account, I ran into the following error when running my script:

The job failed because it could not install distro python package imported in automation account. Error: More than one distribution names were found in python module distro.

I've tried searching for solutions, installed an earlier version of the package (1.7.0, was using 1.8.0), but no success. I installed the distro-1.8.0-py3-none-any.whl found on PyPi, but couldn't find a specific win-amd64 version. Any ideas how I might solve this, which could include using a different method to using GPT in my project? Thanks for any help.

Edit: I just found a very janky solution that works:

import subprocess
subprocess.run(["pip", "install", "distro"]) 

Would love to know if there is a better solution.

Azure Automation
Azure Automation
An Azure service that is used to automate, configure, and install updates across hybrid environments.
1,167 questions
{count} votes