Azure / msrest-for-python

The runtime library "msrest" for AutoRest generated Python clients.
MIT License
41 stars 64 forks source link

ImportError: cannot import name ClientRetryPolicy #129

Closed persiaAziz-zz closed 4 years ago

persiaAziz-zz commented 5 years ago

I have an ansible based project which uses ansible Azure RM module. It used to work fine until I installed pythn, azure>=4.0 and ansible[azure] etc on a new dev Ubuntu machine. I see that there was a change where ClientRetryPolicy was moved to universal_http/requests . Can you please help track this issue.

ansible:~/../$ python
Python 2.7.15rc1 (default, Apr 15 2018, 21:51:34)
[GCC 7.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import msrest
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/msrest/__init__.py", line 27, in <module>
    from .configuration import Configuration
  File "/usr/local/lib/python2.7/dist-packages/msrest/configuration.py", line 39, in <module>
    from .pipeline import (
ImportError: cannot import name ClientRetryPolicy
lmazuel commented 5 years ago

That's weird, I cannot reproduce it

> python
Python 2.7.13 (v2.7.13:a06454b1afa1, Dec 17 2016, 20:42:59) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import msrest
>>>

Also, if you look at the stacktrace: from .pipeline import ( on line 39, this doesn't correspond to line 39 I have: https://github.com/Azure/msrest-for-python/blob/3189c98f8d0c62829a5bab0de5605d6c1aaeb192/msrest/configuration.py#L39

So I'm unsure about what to do here :/

Could you confirm msrest.__version__?

gustavomcarmo commented 5 years ago

The Ansible Azure modules are too restricted to specific Python packages, as can be seen in:

BTW, the Ansible version 2.7.4 has just been released.

lmazuel commented 5 years ago

Cannot reproduce it:

> pip install -r https://raw.githubusercontent.com/ansible/ansible/v2.7.4/packaging/requirements/requirements-azure.txt
Collecting packaging (from -r https://raw.githubusercontent.com/ansible/ansible/v2.7.4/packaging/requirements/requirements-azure.txt (line 1))
...
Successfully installed PyJWT-1.6.4 adal-1.2.0 applicationinsights-0.11.7 argcomplete-1.9.4 asn1crypto-0.24.0 azure-cli-core-2.0.35 azure-cli-nspkg-3.0.2 azure-common-1.1.11 azure-graphrbac-0.40.0 azure-keyvault-1.0.0a1 azure-mgmt-batch-4.1.0 azure-mgmt-compute-2.1.0 azure-mgmt-containerinstance-0.4.0 azure-mgmt-containerregistry-2.0.0 azure-mgmt-containerservice-3.0.1 azure-mgmt-dns-1.2.0 azure-mgmt-keyvault-0.40.0 azure-mgmt-marketplaceordering-0.1.0 azure-mgmt-monitor-0.5.2 azure-mgmt-network-1.7.1 azure-mgmt-nspkg-2.0.0 azure-mgmt-rdbms-1.2.0 azure-mgmt-resource-1.2.2 azure-mgmt-sql-0.7.1 azure-mgmt-storage-1.5.0 azure-mgmt-trafficmanager-0.50.0 azure-mgmt-web-0.32.0 azure-nspkg-2.0.0 azure-storage-0.35.1 bcrypt-3.1.4 certifi-2018.11.29 cffi-1.11.5 chardet-3.0.4 colorama-0.4.1 cryptography-2.4.2 entrypoints-0.2.3 humanfriendly-4.17 idna-2.7 isodate-0.6.0 jmespath-0.9.3 keyring-17.0.0 knack-0.3.3 msrest-0.4.29 msrestazure-0.4.31 oauthlib-2.1.0 packaging-18.0 paramiko-2.4.2 pyOpenSSL-18.0.0 pyasn1-0.4.4 pycparser-2.19 pygments-2.3.0 pynacl-1.3.0 pyparsing-2.3.0 pyreadline-2.1 python-dateutil-2.7.5 pywin32-ctypes-0.2.0 pyyaml-3.13 requests-2.20.1 requests-oauthlib-1.0.0 six-1.11.0 tabulate-0.8.2 urllib3-1.24.1 wheel-0.30.0

then

> python
Python 3.6.3 (v3.6.3:2c5fed8, Oct  3 2017, 18:11:49) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import msrest
>>>
AdamBJ commented 5 years ago

I also am experiencing this error:

python
Python 2.7.15rc1 (default, Nov 12 2018, 14:31:15)
[GCC 7.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import msrest
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/msrest/__init__.py", line 27, in <module>
    from .configuration import Configuration
  File "/usr/local/lib/python2.7/dist-packages/msrest/configuration.py", line 39, in <module>
    from .pipeline import (
ImportError: cannot import name ClientRetryPolicy
>>>
AdamBJ commented 5 years ago

These are the instructions I followed to get from a freshly-minted Azure VM to this point: https://github.com/Azure/sap-hana/wiki/Running-locally

persiaAziz-zz commented 5 years ago

The problem was my machine somehow ended up having a different version of msrest. I had to pin msrest to 0.6.0 to get it working. I wiped all the packages and python and then did fresh configuration. I have listed the steps in : https://github.com/persiaAziz/sap-hana-1/blob/master/deploy/vm/test/regression_test/bootstrap.sh

lmazuel commented 4 years ago

Closing for inactivity, and likely fixed in recent version. Please open a new issue if necessary