myshell-ai/AIlice

Cannot build Docker container using provided Dockerfile

Closed this issue · 6 comments

Hey there,
when I run the Dockerfile using
docker build -t env4scripter .
as explained in the documentation I get the following error.

 > [10/10] RUN pip3 install pyzmq:
0.580 error: externally-managed-environment
0.580
0.580 × This environment is externally managed
0.580 ╰─> To install Python packages system-wide, try apt install
0.580     python3-xyz, where xyz is the package you are trying to
0.580     install.
0.580
0.580     If you wish to install a non-Debian-packaged Python package,
0.580     create a virtual environment using python3 -m venv path/to/venv.
0.580     Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make
0.580     sure you have python3-full installed.
0.580
0.580     If you wish to install a non-Debian packaged Python application,
0.580     it may be easiest to use pipx install xyz, which will manage a
0.580     virtual environment for you. Make sure you have pipx installed.
0.580
0.580     See /usr/share/doc/python3.12/README.venv for more information.
0.580
0.580 note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.
0.580 hint: See PEP 668 for the detailed specification.
------
Dockerfile:14
--------------------
  12 |     COPY ailice/modules/AScrollablePage.py /scripter/ailice/modules/AScrollablePage.py
  13 |
  14 | >>> RUN pip3 install pyzmq
  15 |
  16 |     EXPOSE 59000-59200
--------------------
ERROR: failed to solve: process "/bin/sh -c pip3 install pyzmq" did not complete successfully: exit code: 1

I managed to bypass this issue by creating a virtual environment.

However, I encountered several issues even after creating a working Docker container.

First of all, several Python packages are missing now, like numpy.
Furthermore, after installing those missing libraries, access to the AIlice modules is not working either and needs to be fixed.
So far, I have not found a solution to this issue.

Thus, I'm not able to use the dockerized method right now.

I still can't reproduce your issue. You can give this cmd a try

docker build --no-cache -t env4scripter .

Still running into the same issue with docker build --no-cache -t env4scripter . which also gives me the error.

grafik

[+] Building 0.0s (0/0)  docker:default
2024/05/06 10:02:09 http2: server: error reading preface from client //./pipe/docker_engine: file has already been close[+] Building 56.6s (14/14) FINISHED                                                                      docker:default
 => [internal] load build definition from Dockerfile                                                               0.0s
 => => transferring dockerfile: 712B                                                                               0.0s
 => [internal] load metadata for docker.io/library/ubuntu:latest                                                   0.5s
 => [internal] load .dockerignore                                                                                  0.0s
 => => transferring context: 2B                                                                                    0.0s
 => CACHED [ 1/10] FROM docker.io/library/ubuntu:latest@sha256:3f85b7caad41a95462cf5b787d8a04604c8262cdcdf9a472b8  0.0s
 => [internal] load build context                                                                                  0.0s
 => => transferring context: 360B                                                                                  0.0s
 => [ 2/10] RUN apt-get update && apt-get install -y python3 python3-pip                                          55.4s
 => [ 3/10] WORKDIR /scripter                                                                                      0.0s
 => [ 4/10] COPY ailice/__init__.py /scripter/ailice/__init__.py                                                   0.0s
 => [ 5/10] COPY ailice/common/__init__.py /scripter/ailice/common/__init__.py                                     0.0s
 => [ 6/10] COPY ailice/common/lightRPC.py /scripter/ailice/common/lightRPC.py                                     0.0s
 => [ 7/10] COPY ailice/modules/__init__.py /scripter/ailice/modules/__init__.py                                   0.0s
 => [ 8/10] COPY ailice/modules/AScripter.py /scripter/ailice/modules/AScripter.py                                 0.0s
 => [ 9/10] COPY ailice/modules/AScrollablePage.py /scripter/ailice/modules/AScrollablePage.py                     0.0s
 => ERROR [10/10] RUN pip3 install pyzmq                                                                           0.4s
------
 > [10/10] RUN pip3 install pyzmq:
0.374 error: externally-managed-environment
0.374
0.374 × This environment is externally managed
0.374 ╰─> To install Python packages system-wide, try apt install
0.374     python3-xyz, where xyz is the package you are trying to
0.374     install.
0.374
0.374     If you wish to install a non-Debian-packaged Python package,
0.374     create a virtual environment using python3 -m venv path/to/venv.
0.374     Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make
0.374     sure you have python3-full installed.
0.374
0.374     If you wish to install a non-Debian packaged Python application,
0.374     it may be easiest to use pipx install xyz, which will manage a
0.374     virtual environment for you. Make sure you have pipx installed.
0.374
0.374     See /usr/share/doc/python3.12/README.venv for more information.
0.374
0.374 note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.
0.374 hint: See PEP 668 for the detailed specification.
------
Dockerfile:14
--------------------
  12 |     COPY ailice/modules/AScrollablePage.py /scripter/ailice/modules/AScrollablePage.py
  13 |
  14 | >>> RUN pip3 install pyzmq
  15 |
  16 |     EXPOSE 59000-59200
--------------------
ERROR: failed to solve: process "/bin/sh -c pip3 install pyzmq" did not complete successfully: exit code: 1

I'm using Docker Desktop 4.29.0 (145265) on Windows 11. If you need any further information, please let me know.

Due to some network issues in my area, I've been unable to establish a suitable working environment for addressing your question. However, the cause of this problem should be clear, and you can refer to this post:

https://stackoverflow.com/questions/77028925/docker-compose-fails-error-externally-managed-environment

If you want a short answer, you might consider changing 'RUN pip3 install pyzmq' in the Dockerfile to 'RUN pip3 install pyzmq --break-system-packages' and see if it works.

Please let me know the result. If the problem is solved, I will consider updating the Dockerfile.

No worries.

I used RUN pip3 install pyzmq --break-system-packages as you suggested.
With the additional statement, the Docker container was created successfully.

grafik

Then I followed your descriptions in the documentation
However, when running the container I still get the numpy is missing error message:

2024-05-10 08:15:10 Traceback (most recent call last):
2024-05-10 08:15:10   File "<frozen runpy>", line 198, in _run_module_as_main
2024-05-10 08:15:10   File "<frozen runpy>", line 88, in _run_code
2024-05-10 08:15:10   File "/scripter/ailice/modules/AScripter.py", line 8, in <module>
2024-05-10 08:15:10     from ailice.common.lightRPC import makeServer
2024-05-10 08:15:10   File "/scripter/ailice/common/lightRPC.py", line 11, in <module>
2024-05-10 08:15:10     import numpy
2024-05-10 08:15:10 ModuleNotFoundError: No module named 'numpy'

Dockerfile extension:
RUN pip3 install numpy --break-system-packages
Adding this install to the Dockerfile works with no issues.
Leading to the final error:

2024-05-10 08:21:01 Traceback (most recent call last):
2024-05-10 08:21:01   File "<frozen runpy>", line 198, in _run_module_as_main
2024-05-10 08:21:01   File "<frozen runpy>", line 88, in _run_code
2024-05-10 08:21:01   File "/scripter/ailice/modules/AScripter.py", line 8, in <module>
2024-05-10 08:21:01     from ailice.common.lightRPC import makeServer
2024-05-10 08:21:01   File "/scripter/ailice/common/lightRPC.py", line 17, in <module>
2024-05-10 08:21:01     from ailice.common.ADataType import *
2024-05-10 08:21:01 ModuleNotFoundError: No module named 'ailice.common.ADataType'

Ah, I forgot to update some new dependencies and files in the Dockerfile. Please try with the latest code from the master branch, it should work now.

Yes, now the Docker container is running 😄

I think updating the documentation and explaining the Docker usage in more depth would be beneficial.