首页 > 解决方案 > 运行 Dockerfile 时,python:无法打开文件 'setup.py':[Errno 2] 没有这样的文件或目录

问题描述

我正在尝试使用 Dockerfile 构建图像:sudo docker build 。-f Dockerfile

我正在使用的 Dockerfile:

FROM python:3.6.8-alpine
WORKDIR /usr/app

COPY . ./

RUN pip install --upgrade pip
RUN pip install --upgrade setuptools
RUN pip install -r requirements.txt


RUN export GOOGLE_APPLICATION_CREDENTIALS="/app/static/*******.json"
EXPOSE 5000
ENTRYPOINT [ "python" ]
CMD [ "app.py" ]

要求.txt

Flask-RESTful==0.3.8
Flask==1.1.2
google-cloud-documentai==0.3.0

面临的问题如下:

  ERROR: Command errored out with exit status 1:
     command: /usr/local/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-v7prcez8/grpcio/setup.py'"'"'; __file__='"'"'/tmp/pip-install-v7prcez8/grpcio/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-x0mxi6mn
         cwd: /tmp/pip-install-v7prcez8/grpcio/
    Complete output (11 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-install-v7prcez8/grpcio/setup.py", line 212, in <module>
        if check_linker_need_libatomic():
      File "/tmp/pip-install-v7prcez8/grpcio/setup.py", line 172, in check_linker_need_libatomic
        stderr=PIPE)
      File "/usr/local/lib/python3.6/subprocess.py", line 729, in __init__
        restore_signals, start_new_session)
      File "/usr/local/lib/python3.6/subprocess.py", line 1364, in _execute_child
        raise child_exception_type(errno_num, err_msg, err_filename)
    FileNotFoundError: [Errno 2] No such file or directory: 'cc': 'cc'
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
The command '/bin/sh -c pip install -r requirements.txt' returned a non-zero code: 

除此之外:python setup.py egg_info 给我下面的日志

python: can't open file 'setup.py': [Errno 2] No such file or directory

任何修复或线索都会对我有所帮助。

标签: pythondockerflask

解决方案


推荐阅读