Skip to content

exercise 1 of chapter 6 #28

@hiddenblue

Description

@hiddenblue

In this part, the dockerfile didn't point out the a specific Python3 version and build the image with newest python3 version by default ,which cause some problems.
For example , for python 3.10, some old features were removed.

["Awaitable", "Coroutine", "AsyncIterable", "AsyncIterator", "AsyncGenerator", "Hashable", "Iterable", "Iterator", "Generator", "Reversible", "Sized", "Container", "Callable", "Collection", "Set", "MutableSet", "Mapping", "MutableMapping", "MappingView", "KeysView", "ItemsView", "ValuesView", "Sequence", "MutableSequence", "ByteString"]

if we build the target docker image with the dockfile in sourcecode, we will capture some bugs

Collecting peewee==3.0.4
  Downloading peewee-3.0.4.tar.gz (592 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 592.1/592.1 kB 2.7 MB/s eta 0:00:00
  Preparing metadata (setup.py): started
  Preparing metadata (setup.py): finished with status 'error'
  error: subprocess-exited-with-error

  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [11 lines of output]
      /tmp/pip-install-mjill3ii/peewee_8a9f4baa9bdb444c9f5b97bab68d2996/setup.py:22: UserWarning: Cython C extensions for peewee will NOT be built, because Cython does not seem to be installed. To enable Cython C extensions, install Cython >=0.22.1.
        warnings.warn('Cython C extensions for peewee will NOT be built, because '
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "/tmp/pip-install-mjill3ii/peewee_8a9f4baa9bdb444c9f5b97bab68d2996/setup.py", line 66, in <module>
          version=__import__('peewee').__version__,
                  ^^^^^^^^^^^^^^^^^^^^
        File "/tmp/pip-install-mjill3ii/peewee_8a9f4baa9bdb444c9f5b97bab68d2996/peewee.py", line 157, in <module>
          from collections import Callable
      ImportError: cannot import name 'Callable' from 'collections' (/usr/local/lib/python3.11/collections/__init__.py)
      [end of output]

we can see it uses the python3.11 by default.
After replacing python3 with python 3.11, I solved the problem

So, I think it's better to point out a specific python3 version in your dockerfiles.
like python 3.7
FROM python:3.7-alpine

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions