question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`az --version` fails with SyntaxError on Python 3

See original GitHub issue

Description

az --version fails with SyntaxError on Python 3 due to Python 2 only library futures being installed.

Installing azure-cli 2.0.10 with pip on Python 3.6.1 produces this output. Importantly, these lines appear:

Collecting futures (from azure-multiapi-storage==0.1.0->azure-cli-vm->azure-cli)
  Downloading futures-3.1.1.tar.gz

Subsequently, operations in that environment that require pip will fail when compileall, which imports concurrent, is imported. For example:

$ PYTHONPATH=/opt/azure python -c "import pip"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/opt/azure/pip/__init__.py", line 28, in <module>
    from pip.vcs import git, mercurial, subversion, bazaar  # noqa
  File "/opt/azure/pip/vcs/subversion.py", line 9, in <module>
    from pip.index import Link
  File "/opt/azure/pip/index.py", line 31, in <module>
    from pip.wheel import Wheel, wheel_ext
  File "/opt/azure/pip/wheel.py", line 6, in <module>
    import compileall
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/compileall.py", line 20, in <module>
    from concurrent.futures import ProcessPoolExecutor
  File "/opt/azure/concurrent/futures/__init__.py", line 8, in <module>
    from concurrent.futures._base import (FIRST_COMPLETED,
  File "/opt/azure/concurrent/futures/_base.py", line 381
    raise exception_type, self._exception, self._traceback
                        ^
SyntaxError: invalid syntax

A similar traceback will appear with az --version when it imports pip.

Futures declares that it’s Python 2 only, so shouldn’t be installed on Python 3.


Environment summary

Install Method: How did you install the CLI? (e.g. pip, interactive script, apt-get, Docker, MSI, nightly)
Answer here: pip

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

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

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

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
jaracocommented, Jul 7, 2017

I was able to work around the issue by manually removing the concurrent package and then uninstalling futures.

$ rm -R /opt/azure/concurrent
$ PYTHONPATH=/opt/azure python -m pip uninstall -y futures
Uninstalling futures-3.1.1:
  Successfully uninstalled futures-3.1.1
0reactions
jiaslicommented, Jul 22, 2021

@afelthe, Azure CLI has dropped support for Python 2 (https://github.com/Azure/azure-cli/pull/11363). Are you using the latest Azure CLI?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Invalid Syntax : Azure CLI with Python
I'm using the same command by wrapping it in Python as most of my code is in this format. But it is throwing...
Read more >
Invalid Syntax in Python: Common Reasons for SyntaxError
In this step-by-step tutorial, you'll see common examples of invalid syntax in Python and learn how to resolve the issue. If you've ever...
Read more >
Common Python 3 Error Messages (and How to Eliminate ...
List of Error Messages · SyntaxError: invalid syntax · IndentationError: expected an indented block · IndentationError: unexpected indent · NameError: global name ' ......
Read more >
UsePythonVersion@0 - Use Python version v0 task
Use Python version v0 # Use the specified version of Python from the tool cache, optionally adding it to the PATH.
Read more >
Solved: Could not determine stack version for component
The above error indicates that you might be using Python3. hdp_select.py was not compatible with python 3. Ambari 2.6.x Python requirement: ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found