ImportError: cannot import name 'Markup' from 'jinja2.utils' (/usr/local/lib/python3.8/site-packages/jinja2/utils.py)
This error started appearing after a recent deployment to K8s. However building the image and running the container locally(Both on Windows and Linux machines) using docker-compose produces no errors.
The image K8s uses is hosted in aws ECR, strangely I am unable to reproduce the error by pulling this image and running it locally. It works exactly as expected. There doesn't seem to be any issue with the image itself.
The code where jinjasql is used hasn't changed either.
I am at a loss as to how this is occurring, any ideas would be appreciated.
Python version is 3.8. Kubernetes 1.21.
Related
When I run mlflow UI inside my repository and environment (anaconda), I receive the following error
Cannot open C:\Users\XXX\Anaconda3\envs\haea\Scripts\waitress-serve-script.py
Running the mlflow server failed. Please see the logs above for details
When I checked the anaconda environment folder, I don't see a waitress-serve-script there, that might be the reason, but I can't find other online resources for the issue. Any recommendations would help.
What I have tried so far
Reinstalling mlflow
Creating a new environment
Manually install waitress (pip install waitress)
I have an application with many serverless functions deployed to AWS lambda. These functions use Python 3.7 runtime environment. But yesterday after deploying some minor changes, few of these functions stopped working with the error.
[ERROR] Runtime.ImportModuleError: Unable to import module 'functions.graphql.lambda.user_balance': No module named 'setuptools._distutils'
The weird thing is that the functions which are throwing this error were not changed and other functions are working without any issues. No python module was added/removed.
Just to check if the code change has anything to do with this error, I tried deploying a previous version. But the error persists.
I used the serverless framework for deployment.
It looks like this is an issue that started happening for all Python users as of yesterday as the set up tools got updated, but PIP did not.
According to this GitHub issue there is a temporary workaround until this is actually fixed.
Setting environment variable SETUPTOOLS_USE_DISTUTILS=stdlib is a workaround, e.g.:
export SETUPTOOLS_USE_DISTUTILS=stdlib
pip3 install ....
My assumption would be that you could add this as an environment variable for the Lambda possibly through the serverless config?
This is the bug in setuptools https://github.com/pypa/setuptools/issues/2353. Follow the below temporary workaround.
Linux
export SETUPTOOLS_USE_DISTUTILS=stdlib
Windows
set SETUPTOOLS_USE_DISTUTILS=stdlib
After that, execute the pip command.
pip install XXXXX
I'm deploying a lambda on AWS that uses the Sharp module to resize an image.
Despite using linux to deploy the following error happens:
"Something went wrong installing the sharp module,
Module parse failed: Unexpected character 'u007f' (1: 0),
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders,
(Source code omitted for this binary file), "
In my research I saw that the problem was associated with the OS. That it was necessary to install sharp using "npm install --arch = x64 --platform = linux sharp".
However, the problem continues to happen.
Even using linux x84_64 this problem happens, does anyone know what it could be?
I am trying to deploy a small python 3.7 code which uses "pdftotext" on AWS-Lambda. I was able to run the code successfully on my local machine (Mac). Using virtual-environment as specified by AWS documentation, I created a deployment package of the code with pdftotext. However still I am getting module not found error in Lambda. If you have been able to create a complete build package for pdftotext with all its dependencies, can you share please. Thanks in advance.
Using virtual-environment as specified by AWS documentation, I created a deployment package of the code with pdftotext.
import pdftotext
Getting module not found error for pdftotext when testing in AWS-Lambda.
A bit late to the party on the answer to this question, but I asked a similar question here: Get pdftotext Python module running on Lambda
My problem was I was compiling the binary on Amazon Linux 1 when the Python 3.8 lambda runtime uses Amazon Linux 2 shared libraries.
Install the library on an Amazon Linux 2 EC2 instance or docker container, and the library will be usable in your lambda.
Posting this in case it helps someone that comes across this question.
I am new to flask. After installing it in ubuntu-lts, I tried to change the port but was unable to run the flask app from another port as another user is using an existing port.
I get this error :
from flask import Flask, request
ImportError: No module named 'flask'
[INFO] Worker exiting (pid: 34455)
[INFO] Reason: Worker failed to boot.
Where is the mistake - installation or another problem? thank you.
My guess is that you are on wrong dev environment.
Ensure you are on right python version and Flask is installed for that version. Now, what I mean by this is, that, a normal pip install Flask would install Flask for python2.7, but you seem to have tagged python3 in the OP.
If you are intending to develop your Flask application on Python3, you might want to make a virtual environment using that will use Python3, then install flask inside that. Or else, you could tell Python to install Flask for python3 explicitly.
I agree that you might have installed Flask on your system, but I think the one you installed is for Python2 and you are trying to run the flask app in Python3 environment.
These are wild guesses as your question doesn't say exactly what environment setup you are on.