slimtoolkit / slimtoolkit/slim
Python: ModuleNotFoundError: No module named 'traceback'
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 23.4k
- Forks
- 840
- PR merge metrics
- No merged PRs in 30d
Description
I'm trying to minimize a docker container that uses python and I am getting an error. My Dockerfile looks like this:
FROM amazonlinux:latest
RUN yum install -y make gcc nano openssl-devel bzip2-devel libffi-devel tar zip unzip gzip wget mysql mariadb-devel python-devel sqlite-devel aws-cli \
&& cd /tmp \
&& wget https://www.python.org/ftp/python/3.7.3/Python-3.7.3.tgz \
&& tar -xzf Python-3.7.3.tgz \
&& cd Python-3.7.3 \
&& ./configure \
&& make \
&& make altinstall \
&& cd .. \
&& rm -r Python-3.7.3 \
&& rm -r Python-3.7.3.tgz \
&& pip3.7 install scrapy \
&& pip3.7 install mysqlclient \
&& cd /
When I run the container I get the error:
Error processing line 1 of /usr/local/lib/python3.7/site-packages/zope.interface-5.1.0-py3.7-nspkg.pth:
Fatal Python error: initsite: Failed to import the site module
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site.py", line 168, in addpackage
exec(line)
File "<string>", line 1, in <module>
File "<frozen importlib._bootstrap>", line 580, in module_from_spec
AttributeError: 'NoneType' object has no attribute 'loader'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site.py", line 586, in <module>
main()
File "/usr/local/lib/python3.7/site.py", line 573, in main
known_paths = addsitepackages(known_paths)
File "/usr/local/lib/python3.7/site.py", line 349, in addsitepackages
addsitedir(sitedir, known_paths)
File "/usr/local/lib/python3.7/site.py", line 207, in addsitedir
addpackage(sitedir, name, known_paths)
File "/usr/local/lib/python3.7/site.py", line 178, in addpackage
import traceback
ModuleNotFoundError: No module named 'traceback'
The command I am using for building the slim container is:
docker-slim build --http-probe=false python-test-slim
Is there a flag I am missing or something similar? I am new to this project so I am not sure if this issue related to docker-slim. But I would be really happy I could get some help because the results amazing.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Dockerfile and reproduce the build using docker-slim build --http-probe=false python-test-slim. Inspect how the slimmed image handles Python's site initialization and the installed zope.interface namespace package, using the reported traceback import failure as the stopping point. Done means the resulting container starts without this error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, python
- Domain
- devops, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100