AWS Lambda - error on importing pymssql (module not found) - python

Goal is to connect and query SQL Server instance via Lambda's Python code that has following structure:
I tried two configs but both leave me with error:
Option 1: pymssql listed in package/python/requirements.txt
datadog-api-client>=1.6.0
pyodbc>=4.0.32
pymssql>=2.2.2
Option 2: adding lib to zip file as shown here:
Both throw error:
[ERROR] Runtime.ImportModuleError: Unable to import module 'function': No module named 'pymssql._pymssql'

impport cython made it much easier then pip install pymssql to the directory.

Related

No module named kubernetes.dynamic.resource

I try to deploy some .yaml file with code of Kubernetes, but get error
TASK [/cur/develop/inno/777/name.k8s/roles/deploy_k8s_dashboard : Apply the Kubernetes dashboard] **************************************************************************************************************************************************************************************
Monday 17 October 2022 13:52:07 +0200 (0:00:00.836) 0:00:01.410 ********
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: ImportError: No module named kubernetes.dynamic.resource
fatal: [cibd1]: FAILED! => changed=false
error: No module named kubernetes.dynamic.resource
msg: Failed to import the required Python library (kubernetes) on bvm's Python /usr/bin/python. Please read the module documentation and install it in the appropriate location. If the required library is installed, but Ansible is using the wrong Python interpreter, please consult the documentation on ansible_python_interpreter
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: ImportError: No module named kubernetes.dynamic.resource
fatal: [cibd1]: FAILED! => changed=false
error: No module named kubernetes.dynamic.resource
msg: Failed to import the required Python library (kubernetes) on bvm's Python /usr/bin/python. Please read the module documentation and install it in the appropriate location. If the required library is installed, but Ansible is using the wrong Python interpreter, please consult the documentation on ansible_python_interpreter
Could you please help with advice, How can I fix it?
I've had a similar problem. locally I had to execute the following
ansible-galaxy collection install kubernetes.core
On the target server make sure that you have python3 installed as python2 won't be enough. Once that is installed, I also had to define the below in my vars:
ansible_python_interpreter: /bin/python3

ReadTheDocs and autodoc fail to find my package during build

I have been trying to build docs on readthedocs for my debut python package QutiePy. Building the docs works fine locally, but when I try to build on readthedocs, autodoc fails to populate my sections and gives the following warning:
WARNING: autodoc: failed to import class 'main.register' from module 'QutiePy'; the following exception was raised:
No module named 'QutiePy'
WARNING: autodoc: failed to import module 'gates' from module 'QutiePy'; the following exception was raised:
No module named 'QutiePy'
I have tried many configurations of conf.py to try and add my package to PATH etc. but nothing I've tried has worked.
You can view the github repo I am using here, I am using the development branch.
Thanks in advance.
UPDATE: I have posted the RTD log here
UPDATE 2: I have posted the NEW RTD log here
The solution here was to check that my package was importable from PyPI, adding it to my requirements.txt and making sure that 'Install Project' was selected in the RTD advanced settings. I also added sphinxcontrib-napoleon to requirements.txt and imported it in conf.py although I am unsure if this plays a role at all.

"Unable to import module 'lambda_function': libasound.so.2: cannot open shared object file: No such file or directory",

I have created a lambda layer with the following python packages using pip3:
google-cloud-texttospeech and
azure-cognitiveservices-speech
When I use this layer with python3.8 lambda function, I get the error saying,
{
"errorMessage": "Unable to import module 'lambda_function': libasound.so.2: cannot open shared object file: No such file or directory",
"errorType": "Runtime.ImportModuleError"
}
I removed the azure-cognitiveservices-speech package and the layer works fine with lambda. This means that the culprit is the azure-cognitiveservices-speech package. I couldn't find a way to solve the problem.
Any kind of help will be grately appreciated. Thank you!
So you need to install the package manually on your system and package the same with your lambda zip file as per the documentation
Once installed you can package your python code and the .so files together and upload to AWS lambda. The folder structure for your reference should look like this.
myawesomefunction.py
libasound.so.2

error while uploading python zip file with psycopg2 to aws lambda

I'm trying to add the python zip files to was lambda which contains psycopg2 files in it.I'm getting an error. please try to help
"errorMessage": "Unable to import module 'handler': libpq.so.5: cannot open shared object file: No such file or directory",
"errorType": "Runtime.ImportModuleError"
The point is psycopg2 depends on native code (libpq.so) and your zip file does not contain this dependency.
See here for a solution
Another option is pip install psycopg2-binary. See here for details.

Create a MinIO Bucket in NiFi - Using ExecuteScript processor and (J)python

The 5 S3 related processor present in NiFi cannot create a Minio Bucket.
ListS3
PutS3Object
DeleteS3Object
FetchS3Object
TagS3Object
So I tried to use the ExecuteScript processor and import the python minio module inside of it
In order to do that I install pip3 on my CentOS machine and did pip3 install minio(it installed it in /usr/local/lib/python3.6/site-packages/).
Then in my ExecuteProcessor I set the following configuration :
Script Engine : python
Script File : No value set
Script Body :
from minio import Minio
from minio.error import (ResponseError, BucketAlreadyOwnedByYou,
BucketAlreadyExists)
minioClient = Minio('minio',
access_key='XXXX',
secret_key='XXXX')
Module Directory: /usr/local/lib/python3.6/site-packages/
But I keep getting this error
No module named builtins in at line number 1
Full error :
ExecuteScript[id=3a3e689a-0170-1000-fa4d-b0874062b8cc] ExecuteScript[id=3a3e689a-0170-1000-fa4d-b0874062b8cc] failed to process due to javax.script.ScriptException: ImportError: No module named builtins in at line number 1; rolling back session: org.apache.nifi.processor.exception.ProcessException: javax.script.ScriptException: ImportError: No module named builtins in at line number 1
Hypothesis 1 :
Of what I understand NiFi use Jython and then cannot use C-related Python module, I couldn't find the confirmation that minio-py was one of them but it seems to be the most relevant reason.
is there something I'm missing ?

Categories

Resources