azure-sdk-for-python icon indicating copy to clipboard operation
azure-sdk-for-python copied to clipboard

Fail to import azure.identity(python) in azure batch ubuntu machine

Open limitxiao opened this issue 3 years ago • 7 comments

Describe the bug When i try to import the azure.identity python package in azure batch machine(ubuntuserver 18.04-lts), it always throw out the error like that: ImportError: cannot import name 'RequestsTransport' from 'azure.core.pipeline.transport' (/home/batch-explorer-user/.local/lib/python3.8/site-packages/azure/core/pipeline/transport/init.py) It worked fine in my local win10 machine, and it also worked fine on the batch machine few days ago. The python version is 3.8, i also tried python3.9, still got the same results. The azure-identity version is 1.7.1, and i also tried the latest version 1.11.0, still got the same reults.

Exception or Stack Trace

import azure.identity Traceback (most recent call last): File "", line 1, in File "/home/batch-explorer-user/.local/lib/python3.8/site-packages/azure/identity/init.py", line 10, in from ._credentials import ( File "/home/batch-explorer-user/.local/lib/python3.8/site-packages/azure/identity/_credentials/init.py", line 5, in from .authorization_code import AuthorizationCodeCredential File "/home/batch-explorer-user/.local/lib/python3.8/site-packages/azure/identity/_credentials/authorization_code.py", line 8, in from .._internal.aad_client import AadClient File "/home/batch-explorer-user/.local/lib/python3.8/site-packages/azure/identity/_internal/init.py", line 81, in from .aad_client import AadClient File "/home/batch-explorer-user/.local/lib/python3.8/site-packages/azure/identity/_internal/aad_client.py", line 9, in from .._internal.pipeline import build_pipeline File "/home/batch-explorer-user/.local/lib/python3.8/site-packages/azure/identity/_internal/pipeline.py", line 18, in from azure.core.pipeline.transport import RequestsTransport ImportError: cannot import name 'RequestsTransport' from 'azure.core.pipeline.transport' (/home/batch-explorer-user/.local/lib/python3.8/site-packages/azure/core/pipeline/transport/init.py)

To Reproduce import azure.identity

Code Snippet import azure.identity

Screenshots image

limitxiao avatar Sep 21 '22 03:09 limitxiao

Hi @limitxiao thanks for the feedback, we'll get back to you asap.

l0lawrence avatar Sep 21 '22 15:09 l0lawrence

Hey, @limitxiao. Would you mind doing a pip freeze in your Batch machine and providing the output? This might help clue us in to any weird dependency interactions that may be causing this.

pvaneck avatar Sep 22 '22 00:09 pvaneck

Hey, @limitxiao. Would you mind doing a pip freeze in your Batch machine and providing the output? This might help clue us in to any weird dependency interactions that may be causing this. Hi @pvaneck . Sure this is the output: asn1crypto==0.24.0 attrs==17.4.0 Automat==0.6.0 azure-common==1.1.28 azure-core==1.25.1 azure-identity==1.11.0 azure-mgmt-core==1.3.2 azure-mgmt-datafactory==2.8.0 azure-storage-blob==12.13.1 blinker==1.4 certifi==2018.1.18 cffi==1.15.1 chardet==3.0.4 click==6.7 cloud-init==22.2 colorama==0.3.7 command-not-found==0.3 configobj==5.0.6 constantly==15.1.0 cryptography==38.0.1 distro-info===0.18ubuntu0.18.04.1 httplib2==0.9.2 hyperlink==17.3.1 idna==2.6 incremental==16.10.1 isodate==0.6.1 Jinja2==2.10 jsonpatch==1.16 jsonpointer==1.10 jsonschema==2.6.0 keyring==10.6.0 keyrings.alt==3.0 language-selector==0.1 MarkupSafe==1.0 msal==1.19.0 msal-extensions==1.0.0 msrest==0.7.1 netifaces==0.10.4 oauthlib==3.2.1 PAM==0.4.2 pexpect==4.2.1 portalocker==2.5.1 pyasn1==0.4.2 pyasn1-modules==0.2.1 pycparser==2.21 pycrypto==2.6.1 PyGObject==3.26.1 PyJWT==1.5.3 pyOpenSSL==17.5.0 pyparted==3.11.1 pyserial==3.4 python-apt==1.6.5+ubuntu0.7 python-debian==0.1.32 python-dotenv==0.21.0 pyxdg==0.25 PyYAML==3.12 requests==2.18.4 requests-oauthlib==1.3.1 requests-unixsocket==0.1.5 SecretStorage==2.3.1 service-identity==16.0.0 six==1.16.0 sos==4.3 ssh-import-id==5.7 systemd-python==234 Twisted==17.9.0 typing_extensions==4.3.0 ubuntu-advantage-tools==27.10 ufw==0.36 unattended-upgrades==0.1 urllib3==1.22 WALinuxAgent==2.2.45 zope.interface==4.3.2

limitxiao avatar Sep 22 '22 02:09 limitxiao

Hey, @limitxiao. Would you mind doing a pip freeze in your Batch machine and providing the output? This might help clue us in to any weird dependency interactions that may be causing this. @pvaneck And here is some update. Since the log indicate the root cause was the azure-core. So i retrieve the version of azure-core from 1.25.1-->1.24.1, azure-identity 1.11.0-->1.7.1, pyOpenSSL current version--> latest version. That could temporarily "fix" that issue. But that's was not a offical fix, i think this bug was caused by the update of azure-core package on your side.

limitxiao avatar Sep 22 '22 02:09 limitxiao

Thanks for providing the output.

After some manual testing, I was able to recreate the issue locally. I believe it has something to do with the core/requests/pyopenssl interaction or perhaps just the requests/pyopenssl interaction. Both the requests and pyOpenSSL package versions are pretty old (around 5 years old), so potentially some issues there.

In my testing, keeping the requests version the same (1.18.4) and updating pyOpenSSL to the latest allowed me to successfully import azure.identity. Similarly, not having the PyOpenSSL package at all allowed to import as well. Alternatively, just updating requests to the latest while keeping the old PyOpenSSL version the same allowed me to successfully import.

Can you verify that you are able to import successfully using the latest azure-identity and azure-core with the latest PyOpenSSL or latest requests packages? I think when you updated PyOpenSSL in the process of downgrading core and identity, that fixed your issue.

pvaneck avatar Sep 23 '22 02:09 pvaneck

I try to only upgrade the PyOpenSSL to the latset version, after that i could import the azure.identity. This is strange, this issue did not happen few days ago, and the PyOpenSSL and requests are the default package on python. This means i need to upgrade the PyOpenSSL package every time if i want to use the auzre.identity package, because the batch machine will reset once you start it.

limitxiao avatar Sep 23 '22 02:09 limitxiao

Hi @limitxiao. Thank you for opening this issue and giving us the opportunity to assist. We believe that this has been addressed. If you feel that further discussion is needed, please add a comment with the text “/unresolve” to remove the “issue-addressed” label and continue the conversation.

ghost avatar Sep 23 '22 16:09 ghost

Hi @limitxiao, since you haven’t asked that we “/unresolve” the issue, we’ll close this out. If you believe further discussion is needed, please add a comment “/unresolve” to reopen the issue.

ghost avatar Sep 30 '22 22:09 ghost

Thanks, updating "PyOpenSSL" also worked fine here.

lasleandro avatar Feb 04 '23 16:02 lasleandro