簡體   English   中英

ModuleNotFoundError:沒有名為“azure”的模塊

[英]ModuleNotFoundError: No module named 'azure'

我正在嘗試在 windows 機器上的 msgraph-sdk-python-core上運行一個 exe 文件。 該 exe 是由 PyInstaller 從一個簡單的 python 文件創建的。

主程序

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

在開發環境下運行正常,但是當我將其轉換為Exe時,出現如下錯誤。

>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!

我也試過 --hidden-import 'azure' 但它不起作用。 'azure' 已經停產了,你知道如何用 Exe 做這個嗎?

升級 pyinstaller 解決了它。

pip install --upgrade pyinstaller

pip 安裝對我不起作用。

python --version 

顯示 Python 3.10.5

做過這個:

pip3 install azure-storage-blob azure-identity

然后能夠使用導入的 azure 功能。

from azure.identity import DefaultAzureCredential
from azure.storage.blob import BlobServiceClient, BlobClient, ContainerClient

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM