You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Unable to import module 'app': No module named '_tkinter'", "errorType": "Runtime.ImportModuleError" #90
I am trying to create a docker containers that will run on lambda but I continuously get the error: [Unable to import module 'app': No module named '_tkinter'", "errorType": "Runtime.ImportModuleError" on running the container.
I am sharing the my Dockerfile below:
FROM public.ecr.aws/lambda/python:3.8
RUN yum -y update
RUN yum -y install gcc
RUN yum install -y gcc-c++
RUN yum install -y git
RUN yum install -y which
COPY requirements.txt ./requirements.txt
RUN pip install -r requirements.txt \
&& pip install -e git+https://github.com/ganesh3/icevision.git@master#egg=icevision[inference] --upgrade
RUN mkdir -p ./fonts/
RUN curl -LJO https://raw.githubusercontent.com/airctic/storage/master/SpaceGrotesk-Medium.ttf
RUN cp SpaceGrotesk-Medium.ttf ./fonts/
RUN yum install -y tkinter tcl-devel tk-devel
COPY model_dir ./model_dir
COPY /app/app.py ./
CMD ["app.handler"]
The tkinter package is a basic package in python and hence required but even after installing it is not able to find the package. I logged in to the docker container using the below:
docker exec -it <container_name> sh
Then I logged into the python shell and ran:
>>> import tkinter
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/var/lang/lib/python3.8/tkinter/__init__.py", line 36, in <module>
import _tkinter # If this fails your Python may not be configured for Tk
ModuleNotFoundError: No module named '_tkinter'
Yes, I understand. I am not using tkinter in my project at all. My current understanding is that it is required by pillow package which is a dependency for torchvision. Torchvision being a very common package for deployment, I believe there needs to be a solution to it.
Activity
mespiga commentedon Nov 22, 2022
You aren't going to be able to run tkinter on AWS lambda. Tkinter requires a display.
ganesh3 commentedon Nov 22, 2022
Yes, I understand. I am not using tkinter in my project at all. My current understanding is that it is required by pillow package which is a dependency for torchvision. Torchvision being a very common package for deployment, I believe there needs to be a solution to it.
mespiga commentedon Nov 22, 2022
Just tested
pip install torchvisioninside container and it works withFROM public.ecr.aws/lambda/python:3.8shashidhar100 commentedon Aug 25, 2024
I'm facing same issue here I'm unable to run lambda