I am trying to run an exe file on msgraph-sdk-python-core from windows machine. The exe is created from a simple python file by PyInstaller.
main.py
from azure.identity import ClientSecretCredential from msgraph.core import GraphClient def getGraphClient(): client_secret_credential = ClientSecretCredential( tenant_id="tenant_id", client_id="client_id", client_secret="client_id") gRaphClient = GraphClient(credential=client_secret_credential) return gRaphClient print(getGraphClient()) azure-core==1.26.1 azure-identity==1.12.0 certifi==2022.12.7 cffi==1.15.1 charset-normalizer==2.1.1 cryptography==38.0.4 idna==3.4 msal==1.20.0 msal-extensions==1.0.0 msgraph-core==0.2.2 portalocker==2.6.0 pycparser==2.21 pyinstall==0.1.4 PyJWT==2.6.0 pywin32==305 requests==2.28.1 six==1.16.0 typing_extensions==4.4.0 urllib3==1.26.13 In the development environment, it works fine, but when I convert it to Exe, I get the following error.
>main.exe Traceback (most recent call last): File "main.py", line 1, in <module> ModuleNotFoundError: No module named 'azure' [19104] Failed to execute script 'main' due to unhandled exception! I also tried --hidden-import 'azure' but it doesn't work. 'azure' has already been discontinued, do you know how to do this with Exe?
14 Answers
pip install didnt' work for me.
python --version which showed Python 3.10.5
Did this:
pip3 install azure-storage-blob azure-identity and was then able to use the imported azure functionality.
from azure.identity import DefaultAzureCredential from azure.storage.blob import BlobServiceClient, BlobClient, ContainerClient instead, use this way to install: python3 -m pip install <package_to_install>
I corrected it with pip install azure-mgmt-compute azure-mgmt-storage azure-mgmt-resource
See if it works for you guys
1Upgrading pyinstaller solved it.
pip install --upgrade pyinstaller