Azure / azure-cli

Azure Command-Line Interface
MIT License
3.99k stars 2.98k forks source link

No module named 'azure.cli' Uubntu 18.04 LTS #6678

Closed liorko87 closed 6 years ago

liorko87 commented 6 years ago

I tried to install azure-cli on Ubuntu 18.04. The installation was successfull (I didn't received any error messages. The installation done via apt-get). When I'm trying to run az login the command seems to work correctly, but I received this error:

File "/opt/az/lib/python3.6/site-packages/azure/cli/core/telemetry_upload.py", line 24, in <module> import azure.cli.core.decorators as decorators ModuleNotFoundError: No module named 'azure.cli'

I Have Python 3.6.5 installed.

yugangw-msft commented 6 years ago

//CC :@troydai

troydai commented 6 years ago

This may be caused by inconsistent python path in your system. Can you run az --help and paste the python path here?

troydai commented 6 years ago

The get around this issue, you can run az configure to turn off telemetry.

liorko87 commented 6 years ago

az --help output:

az --help

Group
    az

Subgroups:
    account          : Manage Azure subscription information.
    acr              : Manage Azure Container Registries for private registries within Azure.
    acs              : Manage Azure Container Services.
    ad               : Manage Azure Active Directory Graph entities needed for Role Based Access
                       Control.
    advisor          : Manage Azure Advisor.
    aks              : Manage Azure Kubernetes Services.
    ams              : Manage Azure Media Services resources.
    appservice       : Manage App Service plans.
    backup           : Manage Azure Backups.
    batch            : Manage Azure Batch.
    batchai          : Manage Batch AI resources.
    billing          : Manage Azure Billing.
    cdn              : Manage Azure Content Delivery Networks (CDNs).
    cloud            : Manage registered Azure clouds.
    cognitiveservices: Manage Azure Cognitive Services accounts.
    consumption      : Manage consumption of Azure resources.
    container        : Manage Azure Container Instances.
    cosmosdb         : Manage Azure Cosmos DB database accounts.
    deployment       : Manage Azure Resource Manager deployments at subscription scope.
    disk             : Manage Azure Managed Disks.
    dla              : (PREVIEW) Manage Data Lake Analytics accounts, jobs, and catalogs.
    dls              : (PREVIEW) Manage Data Lake Store accounts and filesystems.
    dms              : Manage Azure Data Migration Service (DMS) instances.
    eventgrid        : Manage Azure Event Grid topics and subscriptions.
    eventhubs        : Manage Azure Event Hubs namespaces, eventhubs, consumergroups and geo
                       recovery configurations - Alias.
    extension        : Manage and update CLI extensions.
    feature          : Manage resource provider features.
    functionapp      : Manage function apps.
    group            : Manage resource groups and template deployments.
    identity         : Managed Service Identities.
    image            : Manage custom virtual machine images.
    iot              : (PREVIEW) Manage Internet of Things (IoT) assets.
    keyvault         : Manage KeyVault keys, secrets, and certificates.
    lab              : Manage Azure DevTest Labs.
    lock             : Manage Azure locks.
    managedapp       : Manage template solutions provided and maintained by Independent Software
                       Vendors (ISVs).
    maps             : Manage Azure Maps.
    monitor          : Manage the Azure Monitor Service.
    mysql            : Manage Azure Database for MySQL servers.
    network          : Manage Azure Network resources.
    policy           : Manage resource policies.
    postgres         : Manage Azure Database for PostgreSQL servers.
    provider         : Manage resource providers.
    redis            : Manage dedicated Redis caches for your Azure applications.
    reservations     : Manage Azure Reservations.
    resource         : Manage Azure resources.
    role             : Manage user roles for access control with Azure Active Directory and service
                       principals.
    servicebus       : Manage Azure Service Bus namespaces, queues, topics, subscriptions, rules and
                       geo-disaster recovery configuration alias.
    sf               : Manage and administer Azure Service Fabric clusters.
    snapshot         : Manage point-in-time copies of managed disks, native blobs, or other
                       snapshots.
    sql              : Manage Azure SQL Databases and Data Warehouses.
    storage          : Manage Azure Cloud Storage resources.
    tag              : Manage resource tags.
    vm               : Manage Linux or Windows virtual machines.
    vmss             : Manage groupings of virtual machines in an Azure Virtual Machine Scale Set
                       (VMSS).
    webapp           : Manage web apps.

Commands:
    configure        : Manage Azure CLI configuration. This command is interactive.
    feedback         : Send feedback to the Azure CLI Team!
    find             : Find Azure CLI commands.
    interactive      : Start interactive mode.
    login            : Log in to Azure.
    logout           : Log out to remove access to Azure subscriptions.

user@user-Latitude-5580:~$ Traceback (most recent call last):
  File "/opt/az/lib/python3.6/site-packages/azure/cli/core/telemetry_upload.py", line 24, in <module>
    import azure.cli.core.decorators as decorators
ModuleNotFoundError: No module named 'azure.cli'
troydai commented 6 years ago

Sorry, my bad. I meant az --version

The Python location is what I'm interested in.

 azure-cli (2.0.41)

acr (2.0.28)
acs (2.1.3)
advisor (0.5.1)
ams (0.1.1)
appservice (0.1.36)
backup (1.1.2)
batch (3.2.4)
batchai (0.3.1)
billing (0.1.8)
cdn (0.0.14)
cloud (2.0.15)
cognitiveservices (0.1.13)
command-modules-nspkg (2.0.1)
configure (2.0.17)
consumption (0.3.1)
container (0.2.1)
core (2.0.41)
cosmosdb (0.1.21)
dla (0.1.0)
dls (0.0.22)
dms (0.0.1)
eventgrid (0.1.12)
eventhubs (0.1.3)
extension (0.1.0)
feedback (2.1.3)
find (0.2.11)
interactive (0.3.25)
iot (0.1.21)
keyvault (2.0.23)
lab (0.0.22)
maps (0.2.0)
monitor (0.1.8)
network (2.1.5)
nspkg (3.0.2)
policyinsights (0.1.0)
profile (2.0.27)
rdbms (0.2.5)
redis (0.2.14)
reservations (0.2.1)
resource (2.0.32)
role (2.0.26)
servicebus (0.1.2)
servicefabric (0.0.12)
sql (2.0.27)
storage (2.0.35)
vm (2.0.35)

Extensions:
webapp (0.2.0)

Python location '/usr/local/opt/python/bin/python3.7'
Extensions directory '/Users/troydai/.azure/cliextensions'

Python (Darwin) 3.7.0 (default, Jun 29 2018, 20:13:13) 
[Clang 9.1.0 (clang-902.0.39.2)]

Legal docs and information: aka.ms/AzureCliLegal
liorko87 commented 6 years ago
azure-cli (2.0.41)

acr (2.0.28)
acs (2.1.3)
advisor (0.5.1)
ams (0.1.1)
appservice (0.1.36)
backup (1.1.2)
batch (3.2.4)
batchai (0.3.1)
billing (0.1.8)
cdn (0.0.14)
cloud (2.0.15)
cognitiveservices (0.1.13)
command-modules-nspkg (2.0.1)
configure (2.0.17)
consumption (0.3.1)
container (0.2.1)
core (2.0.41)
cosmosdb (0.1.21)
dla (0.1.0)
dls (0.0.22)
dms (0.0.1)
eventgrid (0.1.12)
eventhubs (0.1.3)
extension (0.1.0)
feedback (2.1.3)
find (0.2.11)
interactive (0.3.25)
iot (0.1.21)
keyvault (2.0.23)
lab (0.0.22)
maps (0.2.0)
monitor (0.1.8)
network (2.1.5)
nspkg (3.0.2)
policyinsights (0.1.0)
profile (2.0.27)
rdbms (0.2.5)
redis (0.2.14)
reservations (0.2.1)
resource (2.0.32)
role (2.0.26)
servicebus (0.1.2)
servicefabric (0.0.12)
sql (2.0.27)
storage (2.0.35)
vm (2.0.35)

Python location '/opt/az/bin/python3'
Extensions directory '/home/user/.azure/cliextensions'

Python (Linux) 3.6.1 (default, Jul  2 2018, 18:45:10) 
[GCC 7.3.0]

Legal docs and information: aka.ms/AzureCliLegal
troydai commented 6 years ago

Thank you for the info. However, for the time being, I can't think of anything cause this issue. This must be related to your environment settings (not necessarily meant your fault, but some settings we may not expect). And we haven't got a repo and didn't hear others report similar issue yet.

The problem may be caused by an incorrect PYTHON_PATH variable for the telemetry upload process.

For now, I believe the best workaround for you is to turn off the telemetry using az configure command.

lawrencegripper commented 6 years ago

I'm on ubuntu 17.10 and also see this issue after install the CLI through APT. Using az configure then selecting n when asked the telemetry question below worked and I no longer see the error.

Microsoft would like to collect anonymous Azure CLI usage data to improve our CLI.  Participation is voluntary and when you choose to participate, your device automatically sends information to Microsoft about how you use Azure CLI.  To update your choice, run "az configure" again.
Select y to enable data collection. (Y/n): n

Version and env details:

az --version
azure-cli (2.0.41)

acr (2.0.28)
acs (2.1.3)
advisor (0.5.1)
ams (0.1.1)
appservice (0.1.36)
backup (1.1.2)
batch (3.2.4)
batchai (0.3.1)
billing (0.1.8)
cdn (0.0.14)
cloud (2.0.15)
cognitiveservices (0.1.13)
command-modules-nspkg (2.0.1)
configure (2.0.17)
consumption (0.3.1)
container (0.2.1)
core (2.0.41)
cosmosdb (0.1.21)
dla (0.1.0)
dls (0.0.22)
dms (0.0.1)
eventgrid (0.1.12)
eventhubs (0.1.3)
extension (0.1.0)
feedback (2.1.3)
find (0.2.11)
interactive (0.3.25)
iot (0.1.21)
keyvault (2.0.23)
lab (0.0.22)
maps (0.2.0)
monitor (0.1.8)
network (2.1.5)
nspkg (3.0.2)
policyinsights (0.1.0)
profile (2.0.27)
rdbms (0.2.5)
redis (0.2.14)
reservations (0.2.1)
resource (2.0.32)
role (2.0.26)
servicebus (0.1.2)
servicefabric (0.0.12)
sql (2.0.27)
storage (2.0.35)
vm (2.0.35)

Python location '/opt/az/bin/python3'
Extensions directory '/home/lagripp/.azure/cliextensions'

Python (Linux) 3.6.1 (default, Jul  2 2018, 18:38:56) 
[GCC 7.2.0]

Legal docs and information: aka.ms/AzureCliLegal
Traceback (most recent call last):
  File "/opt/az/lib/python3.6/site-packages/azure/cli/core/telemetry_upload.py", line 24, in <module>
    import azure.cli.core.decorators as decorators
ModuleNotFoundError: No module named 'azure.cli'