azure-cli: Getting 'UnicodeEncodeError' on CentOS and Python 2.7
Describe the bug
Using any az acr
command produces a ‘UnicodeEncodeError’. Other ‘az’ commands work without issue.
To Reproduce
Either of the following examples produces the exact same error
az acr list
az acr login --name $ACRNAME
Traceback (most recent call last): File “/usr/lib64/python2.7/logging/init.py”, line 851, in emit msg = self.format(record) File “/usr/lib64/az/lib/python2.7/site-packages/knack/log.py”, line 78, in format msg = logging.StreamHandler.format(self, record) File “/usr/lib64/python2.7/logging/init.py”, line 724, in format return fmt.format(record) File “/usr/lib64/python2.7/logging/init.py”, line 467, in format s = self._fmt % record.dict UnicodeEncodeError: ‘ascii’ codec can’t encode character u’\xa0’ in position 215: ordinal not in range(128)
Expected behavior The expected behavior for the given examples is to list all ACR’s in the current subscription, and then log in to the given ACR. The responses to these commands should be as described in the linked documentation.
Environment summary
- Install method:
sudo yum install azure-cli
- CLI version: 2.0.55 (acr version 2.1.12).
- OS version: CentOS 7.3.1611 (bash)
Full CLI version output
azure-cli (2.0.55)
acr (2.1.12)
acs (2.3.14)
advisor (2.0.0)
ams (0.3.2)
appservice (0.2.11)
backup (1.2.1)
batch (3.4.1)
batchai (0.4.6)
billing (0.2.0)
botservice (0.1.4)
cdn (0.2.0)
cloud (2.1.0)
cognitiveservices (0.2.4)
command-modules-nspkg (2.0.2)
configure (2.0.20)
consumption (0.4.2)
container (0.3.11)
core (2.0.55)
cosmosdb (0.2.7)
dla (0.2.3)
dls (0.1.7)
dms (0.1.1)
eventgrid (0.2.0)
eventhubs (0.3.2)
extension (0.2.3)
feedback (2.1.4)
find (0.2.13)
hdinsight (0.2.0)
interactive (0.4.1)
iot (0.3.4)
iotcentral (0.1.5)
keyvault (2.2.9)
lab (0.1.5)
maps (0.3.3)
monitor (0.2.8)
network (2.3.0)
nspkg (3.0.3)
policyinsights (0.1.0)
profile (2.1.2)
rdbms (0.3.5)
redis (0.3.2)
relay (0.1.2)
reservations (0.4.1)
resource (2.1.8)
role (2.3.0)
search (0.1.1)
security (0.1.0)
servicebus (0.3.2)
servicefabric (0.1.11)
signalr (1.0.0)
sql (2.1.7)
storage (2.3.0)
telemetry (1.0.0)
vm (2.2.12)
Python location '/usr/lib64/az/bin/python'
Extensions directory '/home/dgard/.azure/cliextensions'
Python (Linux) 2.7.5 (default, Nov 6 2016, 00:28:07)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-11)]
Additional context
This problem seems to be related specifically to the acr
subset of commands. Other az
commands work without error.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 18 (10 by maintainers)
Hi Team, I get the error:
when I execute “az storage blob exists”. This is on Red Hat Enterprise Linux Server release 7.6 (Maipo) running Python 2.7.5 on a server in Azure SouthCentral and an identical one in Azure West. What can I do to fix it?
Thanks for the update @dgard1981. I will remove the ACR label since this is affecting other commands.
In the other issue
acr
has aformat
that’s causing the problem and the workaround was to not format the string. There wasn’t a workaround to print the string with Python 2 in some OSs. We ended up asking users to upgrade to Python 3 as well.This specific case, as mentioned in https://github.com/Azure/azure-cli/issues/8312#issuecomment-458332856, the static
logger
is causing the problem so none of the commands in the file would work.