goldmann / docker-squash

Docker image squashing tool
MIT License
848 stars 109 forks source link

'module' object is not callable #232

Closed CharlinChen closed 1 year ago

CharlinChen commented 1 year ago

the docker-squash was successfully insted by pip install docker-squash.However, when I tried docker-squash -h, something went to wrong:

$ docker-squash -h
Sorry, command-not-found has crashed! Please file a bug report at:
https://bugs.launchpad.net/command-not-found/+filebug
Please include the following information with the report:
command-not-found version: 0.3
Python version: 3.6.9 final 0
Distributor ID: Ubuntu
Description:    Ubuntu 18.04.2 LTS
Release:    18.04
Codename:   bionic
Exception information:
'module' object is not callable
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/CommandNotFound/util.py", line 23, in crash_guard
    callback()
  File "/usr/lib/command-not-found", line 89, in main
    cnf = CommandNotFound(options.data_dir)
TypeError: 'module' object is not callable
rnc commented 1 year ago

Using

FROM ubuntu:18.04

RUN apt-get update
RUN apt-get install -y python3-pip
RUN pip3 install docker-squash
RUN python3 --version
RUN docker-squash -h

I see

FROM ubuntu:18.04

RUN apt-get update
RUN apt-get install -y python3-pip
RUN pip3 install docker-squash
RUN python3 --version
RUN docker-squash -h
...
--> b74880bc0234
STEP 4/6: RUN pip3 install docker-squash
Collecting docker-squash
  Downloading https://files.pythonhosted.org/packages/6c/0b/3684b7e34c46045dda03b34be50392c689b23fa8788a0c0f7daf98db35d8/docker-squash-1.1.0.tar.gz
Collecting docker (from docker-squash)
  Downloading https://files.pythonhosted.org/packages/54/f3/7af47ead249fbb798d64a0438bad5c26f17ef6ac5cd324d802038eb10d90/docker-5.0.3-py2.py3-none-any.whl (146kB)
Collecting requests!=2.18.0,>=2.14.2 (from docker->docker-squash)
  Downloading https://files.pythonhosted.org/packages/2d/61/08076519c80041bc0ffa1a8af0cbd3bf3e2b62af10435d269a9d0f40564d/requests-2.27.1-py2.py3-none-any.whl (63kB)
Collecting websocket-client>=0.32.0 (from docker->docker-squash)
  Downloading https://files.pythonhosted.org/packages/35/21/8614b6de7c35d0bc584da13c45b8b08e404eee28a0504c1d00f5e1aa0a23/websocket_client-1.3.1-py3-none-any.whl (54kB)
Collecting urllib3<1.27,>=1.21.1 (from requests!=2.18.0,>=2.14.2->docker->docker-squash)
  Downloading https://files.pythonhosted.org/packages/c5/05/c214b32d21c0b465506f95c4f28ccbcba15022e000b043b72b3df7728471/urllib3-1.26.16-py2.py3-none-any.whl (143kB)
Collecting certifi>=2017.4.17 (from requests!=2.18.0,>=2.14.2->docker->docker-squash)
  Downloading https://files.pythonhosted.org/packages/4c/dd/2234eab22353ffc7d94e8d13177aaa050113286e93e7b40eae01fbf7c3d9/certifi-2023.7.22-py3-none-any.whl (158kB)
Requirement already satisfied: idna<4,>=2.5; python_version >= "3" in /usr/lib/python3/dist-packages (from requests!=2.18.0,>=2.14.2->docker->docker-squash)
Collecting charset-normalizer~=2.0.0; python_version >= "3" (from requests!=2.18.0,>=2.14.2->docker->docker-squash)
  Downloading https://files.pythonhosted.org/packages/06/b3/24afc8868eba069a7f03650ac750a778862dc34941a4bebeb58706715726/charset_normalizer-2.0.12-py3-none-any.whl
Building wheels for collected packages: docker-squash
  Running setup.py bdist_wheel for docker-squash: started
  Running setup.py bdist_wheel for docker-squash: finished with status 'done'
  Stored in directory: /root/.cache/pip/wheels/31/bf/1a/5849b20d9142d2e5363dd1b46de45645d800355dacbf556067
Successfully built docker-squash
Installing collected packages: urllib3, certifi, charset-normalizer, requests, websocket-client, docker, docker-squash
Successfully installed certifi-2023.7.22 charset-normalizer-2.0.12 docker-5.0.3 docker-squash-1.1.0 requests-2.27.1 urllib3-1.26.16 websocket-client-1.3.1
--> 9247d508659e
STEP 5/6: RUN python3 --version
Python 3.6.9
--> e827aa36a85d
STEP 6/6: RUN docker-squash -h
usage: docker-squash [-h] [-v] [--version] [-d] [-f FROM_LAYER] [-t TAG]
                     [-m MESSAGE] [-c] [--tmp-dir TMP_DIR]
                     [--output-path OUTPUT_PATH] [--load-image [LOAD_IMAGE]]
                     image

Docker layer squashing tool

positional arguments:
  image                 Image to be squashed

optional arguments:
  -h, --help            show this help message and exit
  -v, --verbose         Verbose output
  --version             Show version and exit
  -d, --development     Does not clean up after failure for easier debugging
  -f FROM_LAYER, --from-layer FROM_LAYER
                        Number of layers to squash or ID of the layer (or
                        image ID or image name) to squash from. In case the
                        provided value is an integer, specified number of
                        layers will be squashed. Every layer in the image will
                        be squashed if the parameter is not provided.
  -t TAG, --tag TAG     Specify the tag to be used for the new image. If not
                        specified no tag will be applied
  -m MESSAGE, --message MESSAGE
                        Specify a commit message (comment) for the new image.
  -c, --cleanup         Remove source image from Docker after squashing
  --tmp-dir TMP_DIR     Temporary directory to be created and used
  --output-path OUTPUT_PATH
                        Path where the image may be stored after squashing.
  --load-image [LOAD_IMAGE]
                        Whether to load the image into Docker daemon after
                        squashing
COMMIT
--> d123c0bf7679
d123c0bf7679b0ea1d93197b47b203a56c8d1cb8fcf4b28220d32f202ec19b8b

and so therefore it seems your installation/layout is incorrect. Perhaps try posting your installation log and the directory you are running from? You also mentioned pip install ... should that not be pip3 install ?

CharlinChen commented 1 year ago

There seems to be something wrong with my Ubuntu. I switched to a different server and everything is going well