AttributeError: 'module' object has no attribute 'compress'
See original GitHub issueDescribe what happened:
A fresh setup of serverlessrepo-Datadog-Log-Forwarder now results in an error message when using it with a CloudWatch trigger.
[ERROR] 2020-02-05T19:04:31.104Z Exception while forwarding logs in batch
...
Traceback (most recent call last):
File "/var/task/lambda_function.py", line 544, in forward_logs
client.send(batch)
File "/var/task/lambda_function.py", line 295, in send
self._client.send(logs)
File "/var/task/lambda_function.py", line 395, in send
data = compress_logs(data, DD_COMPRESSION_LEVEL)
File "/var/task/lambda_function.py", line 475, in compress_logs
return gzip.compress(bytes(batch, 'utf-8'), compression_level)
AttributeError: 'module' object has no attribute 'compress'
Searching for a solution for this came up with no results. Upon reading https://github.com/DataDog/datadog-serverless-functions/pull/190 and sifting through the Lambda code it turns out that setting DD_USE_COMPRESSION=false
is now required for an out of the box installation to work.
Describe what you expected:
A fresh setup of the log forwarder Lambda should work with a simple configuration.
Steps to reproduce the issue:
Spin up a new Lambda and setup a CloudWatch log group trigger.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:6 (4 by maintainers)
Top Results From Across the Web
GZIP python3 AttributeError: 'module' object has no attribute ...
I'm trying to compress a file using the gzip python lib on an EC2 instance. ... AttributeError: 'module' object has no attribute 'compress'....
Read more >AttributeError: 'module' object has no attribute 'compress'
--> Here we see compress and uncompress modules are present. And I checked for the same in node B and it was found...
Read more >Re: AttributeError: module 'snappy' has no attribute 'compress'
Almost all cosmology/astrophysics/astronomy codes which is my primary interest are not working due to the error: AttributeError: module 'snappy' has no ...
Read more >zstd has no attribute 'compress' - Ask Ubuntu
Save this question. I am getting this error when I was trying to run the command even though I've installed zstd latest version...
Read more >gzip — Support for gzip files — Python 3.11.1 documentation
This module provides a simple interface to compress and decompress files just like the ... and the st_mtime attribute of the object returned...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yes, I can confirm that version 2.4.0 does not work for python2.7 and the SAM application is no longer maintained.
Sorry for the confusion, I believe v2.4.0 was released amid the development of v3.0.0, and it was not well tested against python2.7, which is deprecated. I will release a v2.4.1 patch to the SAM application and set the runtime to python3.7.
We have upgraded to python3.7 since v3.0.0, which offers improved installation and upgrade experience through CloudFormation, please follow these instructions to upgrade: https://github.com/DataDog/datadog-serverless-functions/tree/master/aws/logs_monitoring#upgrade-an-older-version-to-300
Hi @tianchu. I had the same issue. Are you sure version 2.4.0 work fine? compress attribute of gzip is new in python 3.2 according to python docs and template set runtime to python2.7. So it looks like version 2.4.0 is not working unless we set
DD_USE_COMPRESSION=false
. Or sam version of datadog log forwarder is deprecated and not maintained?