Azure-cli: Requests dependency 'urllib3' must be version >= 1.21.1, < 1.22!

Created on 27 May 2017  路  9Comments  路  Source: Azure/azure-cli

Description

Outline the issue here:

victor:ASQ Victor$ az login -u *********** -p **********
Traceback (most recent call last):
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/Users/Victor/lib/azure-cli/lib/python2.7/site-packages/azure/cli/__main__.py", line 23, in <module>
    exit_code = azure.cli.main.main(args)
  File "/Users/Victor/lib/azure-cli/lib/python2.7/site-packages/azure/cli/main.py", line 52, in main
    error_code = handle_exception(ex)
  File "/Users/Victor/lib/azure-cli/lib/python2.7/site-packages/azure/cli/core/util.py", line 34, in handle_exception
    from msrestazure.azure_exceptions import CloudError
  File "/Users/Victor/lib/azure-cli/lib/python2.7/site-packages/msrestazure/__init__.py", line 28, in <module>
    from .azure_configuration import AzureConfiguration
  File "/Users/Victor/lib/azure-cli/lib/python2.7/site-packages/msrestazure/azure_configuration.py", line 33, in <module>
    from msrest import Configuration
  File "/Users/Victor/lib/azure-cli/lib/python2.7/site-packages/msrest/__init__.py", line 27, in <module>
    from .configuration import Configuration
  File "/Users/Victor/lib/azure-cli/lib/python2.7/site-packages/msrest/configuration.py", line 36, in <module>
    import requests
  File "/Users/Victor/lib/azure-cli/lib/python2.7/site-packages/requests/__init__.py", line 61, in <module>
    raise RuntimeError('Requests dependency \'urllib3\' must be version >= 1.21.1, < 1.22!')
RuntimeError: Requests dependency 'urllib3' must be version >= 1.21.1, < 1.22!

Environment summary

Install Method: How did you install the CLI? (e.g. pip, interactive script, apt-get, Docker, MSI, nightly)
Answer here: curl -L https://aka.ms/InstallAzureCli | bash

CLI Version: What version of the CLI and modules are installed? (Use az --version)
Answer here: 2.0.6

OS Version: What OS and version are you using?
Answer here: macOS Sierra 10.12.5

Shell Type: What shell are you using? (e.g. bash, cmd.exe, Bash on Windows)
Answer here:
bash

Packaging

Most helpful comment

@Xurma2 I have been found resolve steps:

  1. jump into /azure-cli/lib/python2.7
  2. pip install urllib3
    If it still doesn't work, the reason is that the python you are running is not under azure-cli folder. It might be located at: /usr/local/lib/python2.7
    In this situation, you have to copy urllib3 manually, like this:
  3. cd /usr/local/lib/python2.7/site-packages
  4. ls (to confirm urllib3 already exists. If not, please run "pip install urllib3")
  5. cp urllib3 /azure-cli/lib/python2.7/site-packages/

When done above, you will run az login correctly.

All 9 comments

I have been gotten this same issue. I am still finding workaround.

@Xurma2 I have been found resolve steps:

  1. jump into /azure-cli/lib/python2.7
  2. pip install urllib3
    If it still doesn't work, the reason is that the python you are running is not under azure-cli folder. It might be located at: /usr/local/lib/python2.7
    In this situation, you have to copy urllib3 manually, like this:
  3. cd /usr/local/lib/python2.7/site-packages
  4. ls (to confirm urllib3 already exists. If not, please run "pip install urllib3")
  5. cp urllib3 /azure-cli/lib/python2.7/site-packages/

When done above, you will run az login correctly.

Getting the same issue when trying to login:

 broda@standartubuntu:/usr/local/lib/python2.7/site-packages$ az login
Traceback (most recent call last):
  File "/usr/lib/python2.7/runpy.py", line 174, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib/python
 broda@standartubuntu:/usr/local/lib/python2.7/site-packages$ az login
Traceback (most recent call last):
  File "/usr/lib/python2.7/runpy.py", line 174, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/home/broda/lib/azure-cli/lib/python2.7/site-packages/azure/cli/__main__.py", line 23, in <module>
    exit_code = azure.cli.main.main(args)
  File "/home/broda/lib/azure-cli/local/lib/python2.7/site-packages/azure/cli/main.py", line 52, in main
    error_code = handle_exception(ex)
  File "/home/broda/lib/azure-cli/local/lib/python2.7/site-packages/azure/cli/core/util.py", line 34, in handle_exception
    from msrestazure.azure_exceptions import CloudError
  File "/home/broda/lib/azure-cli/local/lib/python2.7/site-packages/msrestazure/__init__.py", line 28, in <module>
    from .azure_configuration import AzureConfiguration
  File "/home/broda/lib/azure-cli/local/lib/python2.7/site-packages/msrestazure/azure_configuration.py", line 33, in <module>
    from msrest import Configuration
  File "/home/broda/lib/azure-cli/local/lib/python2.7/site-packages/msrest/__init__.py", line 27, in <module>
    from .configuration import Configuration
  File "/home/broda/lib/azure-cli/local/lib/python2.7/site-packages/msrest/configuration.py", line 36, in <module>
    import requests
  File "/home/broda/lib/azure-cli/local/lib/python2.7/site-packages/requests/__init__.py", line 61, in <module>
    raise RuntimeError('Requests dependency \'urllib3\' must be version >= 1.21.1, < 1.22!')
RuntimeError: Requests dependency 'urllib3' must be version >= 1.21.1, < 1.22!
broda@standartubuntu:/usr/local/lib/python2.7/site-packages$ pip show urllib3
Name: urllib3
Version: 1.21.1
Summary: HTTP library with thread-safe connection pooling, file post, and more.
Home-page: https://urllib3.readthedocs.io/
Author: Andrey Petrov
Author-email: [email protected]
License: MIT
Location: /usr/local/lib/python2.7/dist-packages
Requires:
broda@standartubuntu:/usr/local/lib/python2.7/site-packages$

Had the same issue. Upgrading the package resolved it: pip install --upgrade urllib3

Looks like it is pinned to 1.16 in a few places.

root@add5eb5ef660:/gopath/src/github.com/Azure/acs-engine# pip show urllib3
---
Metadata-Version: 2.0
Name: urllib3
Version: 1.16
Summary: HTTP library with thread-safe connection pooling, file post, and more.
Home-page: https://urllib3.readthedocs.io/
Author: Andrey Petrov
Author-email: [email protected]
Installer: pip
License: MIT
Location: /usr/local/lib/python2.7/dist-packages
Requires: 

I had the same issue and the workaround of copying urllib3 to the azure directory works.
thanks @micli

+1 had the same issue today while trying to follow a docs.microsoft.com article.

Manually copying my installation of urllib3 fixed it. Thanks @micli !

My installation log clearly shows the installer removing the "urllib3" 1.21.1 (that was already installed), then installing "urllib3" 1.16.

  • As devonbarrett suggested above, "urllib3" 1.16 is likely pinned somewhere.
  • I fixed this by manually upgrading "urllib3" after the install, using the command:

    • sudo -H pip install --upgrade urllib3

    • This reinstalls urllib3 1.21.1 and everything works great after this

Note, I've encounter this issue on five-out-of-five Ubuntu 14.04 Instances, so this is not a niche or uncommon problem.

Specifics version:

  • azure-cli (2.0.6)
  • Python (Linux) 2.7.6
  • Ubuntu 14.04
  • Bash 4.3.11(1)

Before installing the Azure CLI - the following were performed:

  • install all OS updates, OS packages (needed), and Python dependancies
  • PIP upgraded to 9.0.1

ISSUE ILLUSTRATION IN CONSOLE OUTPUT

Here's an excerpt from the console output of my install. The uninstall (of the correct urllib3) occurs right after the install of azure-datalake-store:

Running setup.py install for azure-datalake-store ... done
Found existing installation: urllib3 1.21.1
  Uninstalling urllib3-1.21.1:
    Successfully uninstalled urllib3-1.21.1

Soon after, in the final portion of the install "urllib3" 1.16 is installed. It's the very last item listed in the output below (n's added to make it readable and not one long line):

Successfully installed azure-batch-2.0.1 azure-cli-2.0.6 azure-cli-acr-2.0.4 azure-cli-acs-2.0.6
azure-cli-appservice-0.1.6 azure-cli-batch-2.0.4 azure-cli-cdn-0.0.2 azure-cli-cloud-2.0.2
azure-cli-cognitiveservices-0.1.2 azure-cli-command-modules-nspkg-2.0.0 
azure-cli-component-2.0.4 azure-cli-configure-2.0.6 azure-cli-core-2.0.6 
azure-cli-cosmosdb-0.1.6 azure-cli-dla-0.0.6 azure-cli-dls-0.0.6 azure-cli-feedback-2.0.2 
azure-cli-find-0.2.2 azure-cli-interactive-0.3.2 azure-cli-iot-0.1.5 azure-cli-keyvault-2.0.4 
azure-cli-lab-0.0.4 azure-cli-monitor-0.0.4 azure-cli-network-2.0.6 azure-cli-nspkg-3.0.0 
azure-cli-profile-2.0.4 azure-cli-rdbms-0.0.1 azure-cli-redis-0.2.3 azure-cli-resource-2.0.6 
azure-cli-role-2.0.4 azure-cli-sf-1.0.1 azure-cli-sql-2.0.3 azure-cli-storage-2.0.6 
azure-cli-vm-2.0.6 azure-common-1.1.6 azure-datalake-store-0.0.8 azure-graphrbac-0.30.0rc6
azure-keyvault-0.2.0 azure-mgmt-authorization-0.30.0rc6 azure-mgmt-batch-3.0.1 
azure-mgmt-cdn-0.30.2 azure-mgmt-cognitiveservices-1.0.0 azure-mgmt-compute-1.0.0rc1
azure-mgmt-containerregistry-0.2.1 azure-mgmt-datalake-analytics-0.1.4 
azure-mgmt-datalake-nspkg-2.0.0 azure-mgmt-datalake-store-0.1.4 
azure-mgmt-devtestlabs-2.0.0 azure-mgmt-dns-1.0.1 azure-mgmt-documentdb-0.1.3 
azure-mgmt-iothub-0.2.2 azure-mgmt-keyvault-0.31.0 azure-mgmt-monitor-0.2.1 
azure-mgmt-network-1.0.0rc3 azure-mgmt-nspkg-2.0.0 azure-mgmt-rdbms-0.1.0 
azure-mgmt-redis-1.0.0 azure-mgmt-resource-1.1.0rc1 azure-mgmt-sql-0.4.0 
azure-mgmt-storage-1.0.0rc1 azure-mgmt-trafficmanager-0.30.0 azure-mgmt-web-0.32.0 
azure-monitor-0.3.0 azure-multiapi-storage-0.1.0 azure-nspkg-2.0.0 azure-servicefabric-5.6.130
urllib3-1.16

I hope this helps narrow it down. For the record I love azure and the cross-platform/cross-language support. However, I haven't had any difficulties installing the aws CLI, libs (boto, botocore) or even gcloud CLI and libs. This has raised more that a few eyebrows amongst my customers.

Fixed, and we will release at some time this afternon

Thank you & your team!

Was this page helpful?
0 / 5 - 0 ratings