gcloud components update fails with UnicodeDecodeError in MacOS - google-cloud-platform

gcloud components update fails with UnicodeDecodeError in MacOS. Its not clear what would be causing this issue in MacOS and it says Hotfix for UnicodeDecodeError issue affecting logging. How do I get past this issue?
This is my current configuration
gcloud -v
Google Cloud SDK 190.0.0
beta 2017.09.15
bq 2.0.29
core 2018.02.16
gsutil 4.28
Updates are available for some Cloud SDK components. To install them,
please run:
$ gcloud components update
This is the error I get
Container Engine
Traceback (most recent call last):
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/logging/__init__.py", line 859, in emit
msg = self.format(record)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/logging/__init__.py", line 732, in format
return fmt.format(record)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/logging/__init__.py", line 474, in format
s = self._fmt % record.__dict__
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 6: ordinal not in range(128)
Logged from file log.py, line 184
▪ Added container/use_v1_api_client property as an alias of
container/use_v1_api. container/use_v1_api is still supported.
Kubernetes Engine
Traceback (most recent call last):
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/logging/__init__.py", line 859, in emit
msg = self.format(record)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/logging/__init__.py", line 732, in format
return fmt.format(record)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/logging/__init__.py", line 474, in format
s = self._fmt % record.__dict__
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 6: ordinal not in range(128)
Logged from file log.py, line 184
▪ Added --enable-pod-security-policy flag to enable PodSecurityPolicy
enforcement in clusters: gcloud <alpha|beta> container clusters
<create|update> --enable-pod-security-policy
Stackdriver Debugger
Traceback (most recent call last):
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/logging/__init__.py", line 859, in emit
msg = self.format(record)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/logging/__init__.py", line 732, in format
return fmt.format(record)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/logging/__init__.py", line 474, in format
s = self._fmt % record.__dict__
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 6: ordinal not in range(128)
Logged from file log.py, line 184
▪ Changed gcloud beta source upload command to use the .gcloudignore
file if present. If not present and .gitignore is, .gitignore will
still be used. See gcloud topic gcloudignore to learn more.
190.0.1 (2018-02-22)
Traceback (most recent call last):
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/logging/__init__.py", line 859, in emit
msg = self.format(record)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/logging/__init__.py", line 732, in format
return fmt.format(record)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/logging/__init__.py", line 474, in format
s = self._fmt % record.__dict__
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 6: ordinal not in range(128)
Logged from file log.py, line 184
▪ Hotfix for UnicodeDecodeError issue affecting logging.

I can see your Python version is Ok (2.7).
You may need to run gcloud init before trying to update.
If the issue persists or you already ran the aforementioned command, it would be faster to reinstall gcloud. Current version was released today (198.0.0).

Related

CloudFormation - Install and configure CloudWatch Agent to EC2 Instances

I have a CloudFormation template that create ec2 instances using LaunchTemplate, but I want to add cloudwatch agent to the instances, but I can't figure what's wrong.
I have 2 configSets, but the cfn-init get stuck in "02_download_app" > "Command run_app", this part I run a jar file from /.
Here is the output from /var/log/cfn-init-cmd.log, I noticed that after the command run_app the jar get stucked 17:25, and some time later 17:42 I connect to the instance kill the jar and relaunch and it continues the script successfully, I think the error is some encoding problem, but I don't know where: in the jar? in log4j config file?, etc.
2020-06-23 17:25:20,679 main ERROR Console contains an invalid element or attribute "Encoding"
configSets:
setup:
- "01_install_java"
- "02_download_app"
- "03_setupCfnHup"
- "04_config-amazon-cloudwatch-agent"
- "05_restart_amazon-cloudwatch-agent"
updateEnvironment:
- "04_config-amazon-cloudwatch-agent"
- "05_restart_amazon-cloudwatch-agent"
I followed this template, here is part of my template and the cfn-init part.
AWSTemplateFormatVersion: 2010-09-09
Description: >-
Cloudformation template.
Metadata:
Stack:
Value: 2
VersionDate:
Value: 30032020
Identifier:
Value: template-app-stack
Input:
Description: EC2 Instance Types, DB Instance Type and Engine
Output:
Description: Outputs ID of all deployed resources
AWS::CloudFormation::Interface:
Parameters:
#....... other omitted .......#
#....... other omitted .......#
Resources:
#....... other omitted .......#
#backend autoscaling#
rBackendFleet:
Type: AWS::AutoScaling::AutoScalingGroup
Condition: cIsProduction
Properties:
AutoScalingGroupName: !Join [ '-', [!Ref pApplicationName, 'asg', !Ref pApplicationEnvironment, 'backend'] ]
VPCZoneIdentifier: !Ref pBackendSubnets
MinSize: 1
MaxSize: 10
MetricsCollection:
- Granularity: 1Minute
DesiredCapacity: 1
HealthCheckGracePeriod: 300
TargetGroupARNs:
- !Ref rPrivateLoadBalancerTargetGroup
LaunchTemplate:
LaunchTemplateId: !Ref rBackendLaunchTemplate
Version: !GetAtt rBackendLaunchTemplate.LatestVersionNumber
rBackendLaunchTemplate:
Type: AWS::EC2::LaunchTemplate
Metadata:
AWS::CloudFormation::Init:
configSets:
setup:
- "01_install_java"
- "02_download_app"
- "03_setupCfnHup"
- "04_config-amazon-cloudwatch-agent"
- "05_restart_amazon-cloudwatch-agent"
updateEnvironment:
- "04_config-amazon-cloudwatch-agent"
- "05_restart_amazon-cloudwatch-agent"
01_install_java:
packages:
apt:
unzip: []
openjdk-8-jre-headless: []
02_download_app:
files:
/tmp/backend.zip:
source: !Sub
- >-
https://${bucketName}.s3-${region}.amazonaws.com/${objectKey}
- bucketName: !Ref pSourceCodeBucketName
objectKey: !Ref pBackendArtifactObjectKey
region: !Ref AWS::Region
mode: "000644"
owner: "root"
group: "root"
authentication: rolebased
commands:
configure_app:
command: "sudo unzip backend.zip"
test: "sudo ls -la"
cwd: "/tmp"
run_app:
command: "sudo java -jar /tmp/app.jar &"
test: "sudo ps -ef | grep java"
cwd: "/"
04_config-amazon-cloudwatch-agent:
files:
/opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.json:
content: !Sub |
{
"metrics": {
"append_dimensions": {
"AutoScalingGroupName": "${!aws:AutoScalingGroupName}",
"ImageId": "${!aws:ImageId}",
"InstanceId": "${!aws:InstanceId}",
"InstanceType": "${!aws:InstanceType}"
},
"aggregation_dimensions":
[["AutoScalingGroupName"], ["InstanceId", "InstanceType"],[]]
,
"metrics_collected": {
"mem": {
"measurement": [
"mem_used_percent"
]
},
"swap": {
"measurement": [
"swap_used_percent"
]
}
}
},
"logs": {
"logs_collected": {
"files": {
"collect_list": [
{
"file_path": "/profuturo/app/profuturo-rest-comunicaciones/logs/profuturo-rest-comunicaciones.log",
"log_group_name": "/var/log/${pApplicationName}-${pApplicationEnvironment}",
"log_stream_name": "{instance_id}",
"timestamp_format": "%Y-%m-%d %H:%M:%S,%f",
"multi_line_start_pattern": "{timestamp_format}"
}
]
}
}
}
}
05_restart_amazon-cloudwatch-agent:
commands:
01_stop_service:
command: "/opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a stop"
02_start_service:
command: "/opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch-config -m ec2 -c file:/opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.json -s"
03_setupCfnHup:
files:
/etc/cfn/cfn-hup.conf:
content: !Sub |
[main]
stack=${AWS::StackName}
region=${AWS::Region}
verbose=true
interval=1
mode: "000400"
owner: "root"
group: "root"
/etc/cfn/hooks.d/amazon-cloudwatch-agent-auto-reloader.conf:
content: !Sub |
[cfn-auto-reloader-hook]
triggers=post.update
path=Resources.rBackendLaunchTemplate.Metadata.AWS::CloudFormation::Init.04_config-amazon-cloudwatch-agent
action=/opt/aws/bin/cfn-init -v --stack ${AWS::StackName} --resource rBackendLaunchTemplate --configsets updateEnvironment --region ${AWS::Region}
runas=root
mode: "000400"
owner: "root"
group: "root"
/lib/systemd/system/cfn-hup.service:
content: !Sub |
[Unit]
Description=cfn-hup daemon
[Service]
Type=simple
ExecStart=/opt/aws/bin/cfn-hup
Restart=always
[Install]
WantedBy=multi-user.target
mode: "000400"
owner: "root"
group: "root"
commands:
01enable_cfn_hup:
command: "systemctl enable cfn-hup.service"
02start_cfn_hup:
command: "systemctl start cfn-hup.service"
AWS::CloudFormation::Authentication:
rolebased:
type: S3
buckets:
- !Sub ${pSourceCodeBucketName}
roleName:
Ref: pInstanceRole
Properties:
LaunchTemplateName: !Join [ '-', [!Ref pApplicationName, 'lt', !Ref pApplicationEnvironment, 'backend'] ]
LaunchTemplateData:
BlockDeviceMappings:
- Ebs:
VolumeSize: 10
VolumeType: gp2
DeviceName: /dev/sda1
SecurityGroupIds:
- !Ref rBackendSecurityGroup
EbsOptimized: false
IamInstanceProfile:
Arn: !GetAtt rRootInstanceProfile.Arn
ImageId: !Ref pBackendAMI
InstanceType: !Ref pBackendInstanceType
KeyName: !Ref pKeyName
Monitoring:
Enabled: true
UserData:
Fn::Base64: !Sub |
#!/bin/bash -xe
sudo apt-get update -y
sudo apt-get install -y python
sudo apt-get install -y python-setuptools
sudo apt-get install -y python-pip
wget https://s3.amazonaws.com/amazoncloudwatch-agent/ubuntu/amd64/latest/amazon-cloudwatch-agent.deb -O /tmp/amazon-cloudwatch-agent.deb
dpkg -i /tmp/amazon-cloudwatch-agent.deb
sudo mkdir -p /opt/aws/bin
sudo python /usr/lib/python2.7/dist-packages/easy_install.py --script-dir /opt/aws/bin https://s3.amazonaws.com/cloudformation-examples/aws-cfn-bootstrap-latest.tar.gz
sudo /opt/aws/bin/cfn-init -v --stack ${AWS::StackName} --resource rBackendLaunchTemplate --configsets setup,updateEnvironment --region ${AWS::Region}
sudo /opt/aws/bin/cfn-signal -e $? -r "Backend setup done." --stack ${AWS::StackName} --resource rBackendLaunchTemplate --region ${AWS::Region}
........
#App Tier Autoscaling#
#....... other omitted .......#
I watched /var/log/cloud-init-output.log, but no clue of the error, says that is some encoding problem but in what step?
+ sudo /opt/aws/bin/cfn-init -v --stack cwp-prod --resource rBackendLaunchTemplate --configsets setup,updateEnvironment --region us-west-2
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/__init__.py", line 891, in emit
stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 306: ordinal not in range(128)
Logged from file util.py, line 503
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/__init__.py", line 891, in emit
stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 309: ordinal not in range(128)
Logged from file util.py, line 503
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/__init__.py", line 891, in emit
stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 207: ordinal not in range(128)
Logged from file util.py, line 503
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/__init__.py", line 891, in emit
stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 284: ordinal not in range(128)
Logged from file util.py, line 503
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/__init__.py", line 891, in emit
stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 290: ordinal not in range(128)
Logged from file util.py, line 503
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/__init__.py", line 891, in emit
stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 180: ordinal not in range(128)
Logged from file util.py, line 503
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/__init__.py", line 891, in emit
stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 306: ordinal not in range(128)
Logged from file util.py, line 503
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/__init__.py", line 891, in emit
stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 309: ordinal not in range(128)
Logged from file util.py, line 503
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/__init__.py", line 891, in emit
stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 207: ordinal not in range(128)
Logged from file util.py, line 503
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/__init__.py", line 891, in emit
stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 284: ordinal not in range(128)
Logged from file util.py, line 503
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/__init__.py", line 891, in emit
stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 290: ordinal not in range(128)
Logged from file util.py, line 503
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/__init__.py", line 891, in emit
stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 180: ordinal not in range(128)
Logged from file util.py, line 503
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/__init__.py", line 891, in emit
stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 13224: ordinal not in range(128)
Logged from file util.py, line 503
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/__init__.py", line 891, in emit
stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 306: ordinal not in range(128)
Logged from file util.py, line 503
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/__init__.py", line 891, in emit
stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 309: ordinal not in range(128)
Logged from file util.py, line 503
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/__init__.py", line 891, in emit
stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 207: ordinal not in range(128)
Logged from file util.py, line 503
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/__init__.py", line 891, in emit
stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 284: ordinal not in range(128)
Logged from file util.py, line 503
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/__init__.py", line 891, in emit
stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 290: ordinal not in range(128)
Logged from file util.py, line 503
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/__init__.py", line 891, in emit
stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 180: ordinal not in range(128)
Logged from file util.py, line 503
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/__init__.py", line 891, in emit
stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 306: ordinal not in range(128)
Logged from file util.py, line 503
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/__init__.py", line 891, in emit
stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 309: ordinal not in range(128)
Logged from file util.py, line 503
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/__init__.py", line 891, in emit
stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 207: ordinal not in range(128)
Logged from file util.py, line 503
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/__init__.py", line 891, in emit
stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 284: ordinal not in range(128)
Logged from file util.py, line 503
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/__init__.py", line 891, in emit
stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 290: ordinal not in range(128)
Logged from file util.py, line 503
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/__init__.py", line 891, in emit
stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 180: ordinal not in range(128)
Logged from file util.py, line 503
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/__init__.py", line 891, in emit
stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 306: ordinal not in range(128)
Logged from file util.py, line 503
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/__init__.py", line 891, in emit
stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 309: ordinal not in range(128)
Logged from file util.py, line 503
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/__init__.py", line 891, in emit
stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 207: ordinal not in range(128)
Logged from file util.py, line 503
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/__init__.py", line 891, in emit
stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 284: ordinal not in range(128)
Logged from file util.py, line 503
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/__init__.py", line 891, in emit
stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 290: ordinal not in range(128)
Logged from file util.py, line 503
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/__init__.py", line 891, in emit
stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 180: ordinal not in range(128)
Logged from file util.py, line 503
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/__init__.py", line 891, in emit
stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 306: ordinal not in range(128)
Logged from file util.py, line 503
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/__init__.py", line 891, in emit
stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 309: ordinal not in range(128)
Logged from file util.py, line 503
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/__init__.py", line 891, in emit
stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 207: ordinal not in range(128)
Logged from file util.py, line 503
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/__init__.py", line 891, in emit
stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 284: ordinal not in range(128)
Logged from file util.py, line 503
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/__init__.py", line 891, in emit
stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 290: ordinal not in range(128)
Logged from file util.py, line 503
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/__init__.py", line 891, in emit
stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 180: ordinal not in range(128)
Logged from file util.py, line 503
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/__init__.py", line 891, in emit
stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 306: ordinal not in range(128)
Logged from file util.py, line 503
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/__init__.py", line 891, in emit
stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 309: ordinal not in range(128)
Logged from file util.py, line 503
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/__init__.py", line 891, in emit
stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 207: ordinal not in range(128)
Logged from file util.py, line 503
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/__init__.py", line 891, in emit
stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 306: ordinal not in range(128)
Logged from file util.py, line 503
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/__init__.py", line 891, in emit
stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 309: ordinal not in range(128)
Logged from file util.py, line 503
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/__init__.py", line 891, in emit
stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 207: ordinal not in range(128)
Logged from file util.py, line 503
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/__init__.py", line 891, in emit
stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 284: ordinal not in range(128)
Logged from file util.py, line 503
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/__init__.py", line 891, in emit
stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 290: ordinal not in range(128)
Logged from file util.py, line 503
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/__init__.py", line 891, in emit
stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 180: ordinal not in range(128)
Logged from file util.py, line 503
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/__init__.py", line 891, in emit
stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 13233: ordinal not in range(128)
Logged from file util.py, line 503
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/__init__.py", line 891, in emit
stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 306: ordinal not in range(128)
Logged from file util.py, line 503
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/__init__.py", line 891, in emit
stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 309: ordinal not in range(128)
Logged from file util.py, line 503
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/__init__.py", line 891, in emit
stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 207: ordinal not in range(128)
Logged from file util.py, line 503
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/__init__.py", line 891, in emit
stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 284: ordinal not in range(128)
Logged from file util.py, line 503
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/__init__.py", line 891, in emit
stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 290: ordinal not in range(128)
Logged from file util.py, line 503
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/__init__.py", line 891, in emit
stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 180: ordinal not in range(128)
Logged from file util.py, line 503
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/__init__.py", line 891, in emit
stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 114: ordinal not in range(128)
Logged from file util.py, line 503
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/__init__.py", line 891, in emit
stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 130: ordinal not in range(128)
Logged from file util.py, line 503
+ sudo /opt/aws/bin/cfn-signal -e 0 -r 'Backend setup done.' --stack cwp-prod --resource rBackendLaunchTemplate --region us-west-2
ValidationError: Stack arn:aws:cloudformation:us-west-2:496852590701:stack/cwp-prod/80743380-b533-11ea-9ea4-02e40fd26800 is in CREATE_COMPLETE state and cannot be signaled
Cloud-init v. 19.3-41-gc4735dd3-0ubuntu1~18.04.1 running 'modules:final' at Tue, 23 Jun 2020 20:31:35 +0000. Up 23.76 seconds.
2020-06-23 21:31:14,217 - util.py[WARNING]: Failed running /var/lib/cloud/instance/scripts/part-001 [1]
2020-06-23 21:31:14,223 - cc_scripts_user.py[WARNING]: Failed to run module scripts-user (scripts in /var/lib/cloud/instance/scripts)
2020-06-23 21:31:14,226 - util.py[WARNING]: Running module scripts-user (<module 'cloudinit.config.cc_scripts_user' from '/usr/lib/python3/dist-packages/cloudinit/config/cc_scripts_user.py'>) failed
Cloud-init v. 19.3-41-gc4735dd3-0ubuntu1~18.04.1 finished at Tue, 23 Jun 2020 21:31:14 +0000. Datasource DataSourceEc2Local. Up 3602.81 seconds
I guess you are referring this sudo java -jar /tmp/app.jar &? I think you should kill it in your Init after your test finishes.
One way to do this could be as follows:
run_app:
command: |
sudo java -jar /tmp/app.jar &
PROCESS_ID=$!
test: "sudo ps -ef | grep java"
cwd: "/"
run_app_kill:
command: "sudo kill -9 $PROCESS_ID"
I think also sudo is not needed in general. Since you are not numbering the steps, have to make sure run_app_kill runs after run_app.
After some research and looking other related questions, I found that the problem was the output of the command sudo java -jar /tmp/app.jar &, (up to here I didn't know if the output was too long or the ascii characters of the banner), this jar is an spring boot app and by default the logger was in DEBUG mode, so I tried to reduce output by setting INFO, but it didn't worked, then I realized that maybe the spring boot banner is causing this, so I run the app redirecting the output to /dev/null, after that, the cfn-script ran all the configSets successfully.
sudo java -jar /tmp/app.jar > /dev/null 2>&1 &
+ sudo /opt/aws/bin/cfn-init -v --stack cwp-prod --resource rBackendLaunchTemplate --configsets setup --region us-west-2
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/__init__.py", line 891, in emit
stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 114: ordinal not in range(128)
Logged from file util.py, line 503
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/__init__.py", line 891, in emit
stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 130: ordinal not in range(128)
Logged from file util.py, line 503
More info here:
http://www.codeandcompost.com/post/cfn,-utf8-and-two-days-i%E2%80%99ll-never-get-back
https://forums.aws.amazon.com/thread.jspa?threadID=182478

Spyder Launch Error [UnicodeDecodeError] : ubuntu 14.04; Anaconda4.2; Python 2.7.12; Spyder 3

When I run spyder on command line, I got error message like below.
Traceback (most recent call last): File
"/home/park/anaconda2/lib/python2.7/site-packages/spyder/app/mainwindow.py",
line 2998, in main
mainwindow = run_spyder(app, options, args) File "/home/park/anaconda2/lib/python2.7/site-packages/spyder/app/mainwindow.py",
line 2902, in run_spyder
main.setup() File "/home/park/anaconda2/lib/python2.7/site-packages/spyder/app/mainwindow.py",
line 1153, in setup
self.setup_layout(default=False) File "/home/park/anaconda2/lib/python2.7/site-packages/spyder/app/mainwindow.py",
line 1414, in setup_layout
self.setup_default_layouts('default', settings) File "/home/park/anaconda2/lib/python2.7/site-packages/spyder/app/mainwindow.py",
line 1593, in setup_default_layouts
widget.toggle_view(True) File "/home/park/anaconda2/lib/python2.7/site-packages/spyder/plugins/ipythonconsole.py",
line 677, in toggle_view
self.create_new_client(give_focus=False) File "/home/park/anaconda2/lib/python2.7/site-packages/spyder/plugins/ipythonconsole.py",
line 886, in create_new_client
self.connect_client_to_kernel(client) File "/home/park/anaconda2/lib/python2.7/site-packages/spyder/plugins/ipythonconsole.py",
line 903, in connect_client_to_kernel
km, kc = self.create_kernel_manager_and_kernel_client(connection_file) File
"/home/park/anaconda2/lib/python2.7/site-packages/spyder/plugins/ipythonconsole.py",
line 1276, in create_kernel_manager_and_kernel_client
kernel_manager._kernel_spec = self.create_kernel_spec() File "/home/park/anaconda2/lib/python2.7/site-packages/spyder/plugins/ipythonconsole.py",
line 1256, in create_kernel_spec
uv = to_text_string(v) File "/home/park/anaconda2/lib/python2.7/site-packages/spyder/py3compat.py",
line 136, in to_text_string
return unicode(obj) UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 73: ordinal not in range(128)
I have been searching the solution but I can not get the solution.
I have tried :
Reinstall using "pip install spyder"
Reinstall using "conda install spyder"
How do I fix it. If you give me some ideas, I can really appreciate for this.
Thanks.
I also had some problems with Spyder 3 on Ubuntu 14.04. So I uninstalled it and reinstalled Spyer 2, which then worked just fine for me. If you don't mind using Spyder 2, you can run the following command to see if it works for you
conda install -c spyder-ide spyder=2.3.9

Django 1.9 + Python 2.7: style.css did not take effect due to UnicodeDecodeError

I am trying to follow Django tutorial (Django 1.9, Python 2.7) to implement my polls project, but style.css did not take effect (neither the color nor the backgroud image).
https://docs.djangoproject.com/en/1.9/intro/tutorial06/
When running the server, I observed the UnicodeDecodeError due to 'ascii' codec.
UnicodeDecodeError: 'ascii' codec can't decode byte 0xb0 in position 1: ordinal not in range(128)
I followed the suggestion by set system default encoding to utf8, but when server was running it threw similar error due to 'utf8'.
How to fix: "UnicodeDecodeError: 'ascii' codec can't decode byte"
UnicodeDecodeError: 'utf8' codec can't decode byte 0xb0 in position 1: invalid start byte
So I think neither ascii nor utf8 is enough, and how can I fix it?
I saw some posts provided some suggestion like json.loads, but I have no idea how to add in my Django project.
json.loads(unicode(opener.open(...), "ISO-8859-1")),
utf8' codec can't decode byte 0x89 in position 15: invalid start byte
UnicodeDecodeError: 'utf8' codec can't decode bytes in position 3-6: invalid data
Issue Full Trace:
[17/Mar/2016 12:26:28] "GET /polls/ HTTP/1.1" 200 161
Traceback (most recent call last):
File "C:\Python27\lib\wsgiref\handlers.py", line 85, in run
self.result = application(self.environ, self.start_response)
File "C:\Python27\lib\site-packages\django\contrib\staticfiles\handlers.py", line 64, in __call__
return super(StaticFilesHandler, self).__call__(environ, start_response)
File "C:\Python27\lib\site-packages\django\core\handlers\wsgi.py", line 177, in __call__
response = self.get_response(request)
File "C:\Python27\lib\site-packages\django\contrib\staticfiles\handlers.py", line 54, in get_response
return self.serve(request)
File "C:\Python27\lib\site-packages\django\contrib\staticfiles\handlers.py", line 47, in serve
return serve(request, self.file_path(request.path), insecure=True)
File "C:\Python27\lib\site-packages\django\contrib\staticfiles\views.py", line 40, in serve
return static.serve(request, path, document_root=document_root, **kwargs)
File "C:\Python27\lib\site-packages\django\views\static.py", line 66, in serve content_type, encoding = mimetypes.guess_type(fullpath)
File "C:\Python27\lib\mimetypes.py", line 297, in guess_type
init()
File "C:\Python27\lib\mimetypes.py", line 358, in init db.read_windows_registry()
File "C:\Python27\lib\mimetypes.py", line 258, in read_windows_registry
for subkeyname in enum_types(hkcr):
File "C:\Python27\lib\mimetypes.py", line 249, in enum_types
ctype = ctype.encode(default_encoding) # omit in 3.x!
UnicodeDecodeError: 'utf8' codec can't decode byte 0xb0 in position 1: invalid start byte

Trouble with pip install selenium

I have Vista(please avoid comment ;D)... I'm sure of the right install of pip because I have installed other package but when I try to install selenium by pip that's the result.:
C:\Program Files\Python2.7.6>pip install selenium
Downloading/unpacking selenium Running setup.py
(path:c:\users\gianlu~1\appdata\local\temp\pip_build_Gianluca
«\selenium\setup.py) egg_info for package selenium
Cleaning up...
The line below are in red(this is my comment)
Exception:
Traceback (most recent call last):
File "C:\Program Files\Python2.7.6\lib\site-packages\pip\basecommand.py", line
122, in main
status = self.run(options, args)
File "C:\Program Files\Python2.7.6\lib\site-packages\pip\commands\install.py",
line 278, in run
requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundl
e=self.bundle)
File "C:\Program Files\Python2.7.6\lib\site-packages\pip\req.py", line 1234, i
n prepare_files
req_to_install.assert_source_matches_version()
File "C:\Program Files\Python2.7.6\lib\site-packages\pip\req.py", line 464, in
assert_source_matches_version
% (display_path(self.source_dir), version, self))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xae in position 65: ordinal
not in range(128)
End of the red
Traceback (most recent call last):
File "C:\Program Files\Python2.7.6\lib\runpy.py", line 162, in _run_module_as_
main
"__main__", fname, loader, pkg_name)
File "C:\Program Files\Python2.7.6\lib\runpy.py", line 72, in _run_code
exec code in run_globals
File "C:\Program Files\Python2.7.6\pip.exe\__main__.py", line 9, in <module>
File "C:\Program Files\Python2.7.6\lib\site-packages\pip\__init__.py", line 18
5, in main
return command.main(cmd_args)
File "C:\Program Files\Python2.7.6\lib\site-packages\pip\basecommand.py", line
161, in main
text = '\n'.join(complete_log)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xae in position 80: ordinal
not in range(128)
I'm new of Phyton and that is over for me. The only thing that I can suppose and investigate is that the matter is about the last line "Unicode...".
Thank you for any suggestion.
Yes, really a bad question. I was very tired after a code marathon ;D. Starting from my edit of investigate the unicode error and only after a few hours of sleep I find a lot of intresting and working solution. Here the more considerable and useful link:
Python ez_install : UnicodeDecodeError: 'ascii' codec can't decode byte 0xae in position 11
UnicodeDecodeError : 'ascii' codec can't decode byte 0xe0 in position 0: ordinal not in range(128)
pip install tabulate UnicodeDecodeError

encoding errors when replacing unwanted characters in utf-8 encoded file

Code can be downloaded here:
https://github.com/kelrien/pyretrieval/
whenever I execute my example.py, the following error pops up:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "example.py", line 21, in <module>
docs.append(proc.process(line.decode("utf-8")))
File "pyretrieval\processor.py", line 61, in process
tokens = self.tokenize(string)
File "pyretrieval\processor.py", line 47, in tokenize
temp = temp.replace(char, self.replace_characters[char])
UnicodeDecodeError: 'ascii' codec can't decode byte 0xfc in position 0: ordinal not in range(128)
As you can see - the error happens when trying to replace german umlauts I specified. If I don't use the replace_characters dict and just ignore those umlauts, I'm not getting the error.
I already tried a lot of stuff:
Using the codecs module
Using encode("utf-8") and decode("utf-8") at different
I found a solution. I had to encode the characters I wanted to replace in unicode too(in processor.py).
I already pushed the necessary changes to github. https://github.com/kelrien/pyretrieval