Python pip安装失败,出现ModuleNotFoundError:没有名为'pyexpat'的模块错误

xj3cbfub  于 2022-12-02  发布在  Python
关注(0)|答案(1)|浏览(476)

完整的Docker文件:https://github.com/docker-library/python/blob/master/3.8/bullseye/Dockerfile Docker文件:
'''

ENV PYTHON_PIP_VERSION 22.0.4
#https://github.com/docker-library/python/issues/365
ENV PYTHON_SETUPTOOLS_VERSION 57.5.0
#https://github.com/pypa/get-pip
ENV PYTHON_GET_PIP_URL https://github.com/pypa/get-pip/raw/aeca83c7ba7f9cdfd681103c4dcbf0214f6d742e/public/get-pip.py
ENV PYTHON_GET_PIP_SHA256 d0b5909f3ab32dae9d115aa68a4b763529823ad5589c56af15cf816fca2773d6

RUN set -eux; 
    wget -O get-pip.py "$PYTHON_GET_PIP_URL"; 
    echo "$PYTHON_GET_PIP_SHA256 *get-pip.py" | sha256sum -c -; \
    export PYTHONDONTWRITEBYTECODE=1; \
    python get-pip.py \
        --disable-pip-version-check \
        --no-cache-dir \
        --no-compile \
        "pip==$PYTHON_PIP_VERSION" \
        "setuptools==$PYTHON_SETUPTOOLS_VERSION" ;\
        rm -f get-pip.py; \
        pip --version

ウ错误:Ж

>     python get-pip.py --disable-pip-version-check --no-cache-dir --no-compile pip==22.0.4 setuptools==57.5.0
>     Traceback (most recent call last):
>         File "get-pip.py", line 32098, in <module>
>         main()
>         File "get-pip.py", line 135, in main
>         bootstrap(tmpdir=tmpdir)
>     File "get-pip.py", line 111, in bootstrap
>         monkeypatch_for_cert(tmpdir)
>     File "get-pip.py", line 92, in monkeypatch_for_cert
>         from pip._internal.commands.install import InstallCommand
>     File "<frozen zipimport>", line 259, in load_module
>     File "/tmp/tmpiqi24qri/pip.zip/pip/_internal/commands/install.py", line 16, in <module>
>     File "<frozen zipimport>", line 259, in load_module
>     File "/tmp/tmpiqi24qri/pip.zip/pip/_internal/cli/req_command.py", line 21, in <module>
>     File "<frozen zipimport>", line 259, in load_module
>     File "/tmp/tmpiqi24qri/pip.zip/pip/_internal/index/package_finder.py", line
> 33, in <module>
>     File "<frozen zipimport>", line 259, in load_module
>     File "/tmp/tmpiqi24qri/pip.zip/pip/_internal/req/__init__.py", line 8, in <module>
>     File "<frozen zipimport>", line 259, in load_module
>     File "/tmp/tmpiqi24qri/pip.zip/pip/_internal/req/req_install.py", line 42, in <module>
>     File "<frozen zipimport>", line 259, in load_module
>     File "/tmp/tmpiqi24qri/pip.zip/pip/_internal/operations/install/wheel.py",
> line 39, in <module>
>     File "<frozen zipimport>", line 259, in load_module
>     File "/tmp/tmpiqi24qri/pip.zip/pip/_vendor/distlib/scripts.py", line 16, in <module>
>     File "<frozen zipimport>", line 259, in load_module
>     File "/tmp/tmpiqi24qri/pip.zip/pip/_vendor/distlib/compat.py", line 83, in <module>
>     File "/usr/local/lib/python3.8/xmlrpc/client.py", line 138, in <module>
>         from xml.parsers import expat
>     File "/usr/local/lib/python3.8/xml/parsers/expat.py", line 4, in <module>
>         from pyexpat import *
>     ModuleNotFoundError: No module named 'pyexpat'

“”“尝试将python 3.8添加到我的自定义映像。我可以安装python 3.8.13。我正在将以上行添加到docker文件以安装pip,但得到上面的”pyexpat“模块丢失的错误。
如何添加此模块,是否必须在操作系统级别安装一些软件包?

tct7dpnv

tct7dpnv1#

运行www.example.com之前需要安装expat-dev软件包get-pip.py

RUN \
    set -eu; \
    apk update --no-cache; \
    apk add --no-cache \
        expat-dev \
        ;

相关问题