Aws lambda returns /lib64/libc.so.6: version `GLIBC_2.28' not found - amazon-web-services

I am running an AWS Lambda function that uses one layer with snowflake-connector-python.
To create the layer I use:
docker run -v <your dev directory>:/lambda -it --rm ubuntu
apt-get update
apt-get install python3-pip
apt-get install zip
cd lambda
mkdir -p temp/python
cd temp/python
pip3 install snowflake-connector-python -t .
cd ..
zip -r9 ../snowflake-connector-python.zip .
The lambda returns:
"errorMessage": "Unable to import module 's3PutLambda': /lib64/libc.so.6: version `GLIBC_2.28' not found (required by /opt/python/cryptography/hazmat/bindings/_rust.abi3.so)",
"errorType": "Runtime.ImportModuleError",
"requestId": "baa60d07-c9bb-4b32-a38f-3158eb50da09",
"stackTrace": []
I tried also some other solutions, such as adding to the zip:
pip3 install cryptography==3.4.8
pip3 install bcrypt==3.2.2
The same error was raised.

Finally solved, you need to downgrade snowflake-connector-python version and install it using platform manylinux2010_x86_64.
pip installs packages from latest wheel unless you specify wheels version. The Python library packages I used were newer than the ones in runtime in Lambda backend containers.
If you specify manylinux2010 platform when installing the connector it fixes the issue.
The command I used is:
pip3 install --platform manylinux2010_x86_64 --implementation cp --python 3.8 --only-binary=:all:
--upgrade --target . snowflake-connector-python==2.7.9
Obs:
I have not tested it with higher snowflake-connector-python versions, neither with higher python versions. I use Python 3.8 runtime in AWS Lambda.

Related

How to install python-mysqldb for Python 2.7 in Ubuntu 20.04 (Focal Fossa)?

I've tried "apt-get install python-mysqldb" which results in:
root#ps1svr:~# apt-get install python-mysqldb
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package python-mysqldb is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
E: Package 'python-mysqldb' has no installation candidate
Note: "apt-get install python3-mysqldb" works, however I have a lot of code written for Python 2.x which no longer runs, and this is causing enough problems that I'm probably going to have to reinstall Ubuntu 18.04
Also you can just add the Ubuntu 18.04 repositoery to install the python-mysqldb package:
sudo add-apt-repository 'deb http://archive.ubuntu.com/ubuntu bionic main'
sudo apt update
sudo apt install -y python-mysqldb
This will download, build and install it for all users, using pip
sudo apt install libmysqlclient-dev python2.7-dev
wget https://bootstrap.pypa.io/get-pip.py
sudo python2.7 get-pip.py
sudo wget https://raw.githubusercontent.com/paulfitz/mysql-connector-c/master/include/my_config.h -O /usr/include/mysql/my_config.h
sudo pip2 install MySQL-python
Answer found from MySQLdb install error - _mysql.c:44:23: error: my_config.h: No such file or directory

AWS CDK python client giving error with cdk deploy

My stack:
python 3.6
Node.js 11.3.0
jsii-0.20.11 (automatically installed when aws cdk is installed via npm)
I just tried cdk init and then did pip install -e.
After that, I did cdk deploy and it gives me the following error:
Traceback (most recent call last):
File "app.py", line 3, in <module>
from aws_cdk import core
File "C:\Users\sgoud12\myfolder\myprojects\myapp\cdk\.env\lib\site-packages\aws_cdk\core\__init__.py", line 1967, in <module>
class DependableTrait(metaclass=jsii.JSIIAbstractClass, jsii_type="#aws-cdk/core.DependableTrait"):
TypeError: __new__() got an unexpected keyword argument 'jsii_type'
Subprocess exited with error 1
(.env) C:\Users\sgoud12\myfolder\myprojects\myapp\cdk>
(.env) C:\Users\sgoud12\myfolder\myprojects\myapp\cdk>fs.js:122
throw err;
^
Error: EOF: end of file, read
at Object.readSync (fs.js:517:3)
at SyncStdio.readLine (C:\Users\sgoud12\myfolder\myprojects\myapp\cdk\.env\lib\site-packages\jsii\_embedded\jsii\jsii-runtime.js:13350:25)
at InputOutput.read (C:\Users\sgoud12\myfolder\myprojects\myapp\cdk\.env\lib\site-packages\jsii\_embedded\jsii\jsii-runtime.js:13300:34)
at KernelHost.run (C:\Users\sgoud12\myfolder\myprojects\myapp\cdk\.env\lib\site-packages\jsii\_embedded\jsii\jsii-runtime.js:7231:32)
at Immediate.setImmediate (C:\Users\sgoud12\myfolder\myprojects\myapp\cdk\.env\lib\site-packages\jsii\_embedded\jsii\jsii-runtime.js:7239:37)
at processImmediate (timers.js:632:19)
It usually means some kind of versions missmarch: aws-cdk in npm and aws-cdk in python. Given that it's a pretty old question I suppose updating all packages or even reinstall the environment should help.
There are mentions of a similar problem in the official aws-cdk bug tracker:
https://github.com/aws/aws-cdk/issues/3349
https://github.com/aws/aws-cdk/issues/3293
I agree, this is frustrating and hard to find a fix for. Using the links from #Trilliput
My Steps:
Uninstall pip
Update homebrew
Remove the aws cli
Reinstall the aws cli
uninstall aws cdk
reinstall aws cdk
Commands:
sudo pip uninstall pip
brew update
sudo rm /usr/local/bin/aws
sudo rm /usr/local/bin/aws_completer
sudo rm -rf /usr/local/aws-cli
curl "https://awscli.amazonaws.com/AWSCLIV2.pkg" -o "AWSCLIV2.pkg"
sudo installer -pkg AWSCLIV2.pkg -target /
pip3 uninstall aws-cdk.cdk
pip3 install aws-cdk.cdk --use-feature=2020-resolver
That didn't work as I hoped, so I used all of these commands below. I called it to scorched earth reinstall:
sudo pip uninstall pip
brew update
sudo rm /usr/local/bin/aws
sudo rm /usr/local/bin/aws_completer
sudo rm -rf /usr/local/aws-cli
brew uninstall node
brew uninstall pyenv
# CLOSE your terminal window and open a NEW terminal window.
# when you run [which python] you should get /usr/bin/python
# run these commands to remove node and npm
https://gist.github.com/TonyMtz/d75101d9bdf764c890ef
curl "https://awscli.amazonaws.com/AWSCLIV2.pkg" -o "AWSCLIV2.pkg"
sudo installer -pkg AWSCLIV2.pkg -target /
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python get-pip.py
python3 get-pip.py
brew install python3
# old CDK
pip3 uninstall aws-cdk.cdk
#new CDK
pip3 uninstall aws-cdk.core
# NEW CDK
pip3 install aws-cdk.core
#pip3 install aws-cdk.core --use-feature=2020-resolver
# reinstall aws cdk
npm install -g aws-cdk
npm install -g npm#7.0.13
sudo npm install -g npm#7.0.13
npm install -g aws-cdk
sudo npm install -g aws-cdk
sudo -i
sudo npm install -g aws-cdk
cdk --version
Bumping up the python version from 3.6 to 3.7.5 worked like a charm for me

-bash: aws: command not found

I'm on macOS Mojave Version 10.14.5.
I was following the instructions here
Installing the AWS CLI
when I got to the part to type
aws --version
in terminal, and got the response
-bash: aws: command not found
Here's a screenshot of terminal
I looked at the other posts similar to this on stackoverflow, but they seem to apply to different contexts. They have not helped.
you need to install python and pip on your mac in order to install the awscli.
After the installation of python and pip, please use following command to install aws cli with latest version from AWS.
sudo pip install awscli --force-reinstall --upgrade
Install python version 3 or higher And Use this command to download aws cli with python3
curl "https://s3.amazonaws.com/aws-cli/awscli-bundle.zip" -o "awscli-bundle.zip"
unzip awscli-bundle.zip
sudo /usr/local/bin/python3 awscli-bundle/install -i /usr/local/aws -b /usr/local/bin/aws
use AWS official guide here to ensure you are installing the latest version.
I have mac and this fixed the issue
$ curl "https://awscli.amazonaws.com/AWSCLIV2.pkg" -o "AWSCLIV2.pkg"
$ sudo installer -pkg AWSCLIV2.pkg -target /
This command works good for me
sudo apt install awscli

Unable to install pip

I tried installing pip in the following different ways and didn't have any success, any guidance how can I install pip ?
username#machine ~]$ sudo /usr/local/bin/easy_install pip
[sudo] password for username:
Searching for pip
Reading http://pypi.python.org/simple/pip/
Couldn't find index page for 'pip' (maybe misspelled?)
Scanning index of all packages (this may take a while)
Reading http://pypi.python.org/simple/
No local packages or download links found for pip
error: Could not find suitable distribution for Requirement.parse('pip')
[username#machine ~]$ sudo /usr/local/bin/easy_install-2.7 pip
Searching for pip
Reading http://pypi.python.org/simple/pip/
Couldn't find index page for 'pip' (maybe misspelled?)
Scanning index of all packages (this may take a while)
Reading http://pypi.python.org/simple/
No local packages or download links found for pip
error: Could not find suitable distribution for Requirement.parse('pip')
[username#machine ~]$ python -m pip
/usr/local/bin/python: No module named pip
[username#machine ~]$ sudo apt-get install python-pip
sudo: apt-get: command not found
[username#machine ~]$ sudo yum install python-pip
Loaded plugins: security
Setting up Install Process
No package python-pip available.
Error: Nothing to do
Machine configuration:
LSB Version: :base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarch
Distributor ID: OracleServer
Description: Oracle Linux Server release 6.6
Release: 6.6
Codename: n/a
You can try to use the following for python2.7:
sudo apt install python-pip
And if you alternatively want to install on python3:
sudo apt install python3-pip
None of the above worked, I had to do the following for OL7, as per the official docs:
yum install -y oracle-epel-release-el7 oracle-release-el7

Error while installing libapache2-mod-wsgi on linux

easy_install libapache2-mod-wsgi
No local packages or download links found for libapache2modwsgi
error: Could not find suitable distribution for Requirement.parse('libapache2mod wsgi')
libapache2-mod-wsgi is not a python package. You should install it via your distribution package manager. For example, if you are in a debian based distribution:
sudo apt-get install libapache2-mod-wsgi
Or if you are working with Python 3
sudo apt-get install libapache2-mod-wsgi-py3