提问人:XEOX 提问时间:2/23/2022 最后编辑:XEOX 更新时间:2/23/2022 访问量:485
如何修复“无法构建应用程序。错误:无法流式传输生成输出:命令“/bin/sh -c pip install --no-cache-dir -r requirements.txt”
How to fix "Failed to build the app . Error: unable to stream build output: The command '/bin/sh -c pip install --no-cache-dir -r requirements.txt"
问:
我是gcloud的新手,我不知道如何修复这个错误:(
当我尝试将我的 API 部署到 Cloud 运行时,我收到以下错误消息:
Failed to build the app. Error: unable to stream build output: The command '/bin/sh -c pip install --no-cache-dir -r requirements.txt' returned a non-zero code: 1
以下是详细日志:
[0m
[91mWARNING: You are using pip version 21.2.4; however, version 22.0.3 is available.
You should consider upgrading via the '/usr/local/bin/python -m pip install --upgrade pip' command.
[0m
unable to stream build output: The command '/bin/sh -c pip install --no-cache-dir -r requirements.txt' returned a non-zero code: 1
Failed to build the app. Error: unable to stream build output: The command '/bin/sh -c pip install --no-cache-dir -r requirements.txt' returned a non-zero code: 1
这是我尝试在第一个文件(snsr.py)中导入的内容:
import requests
import numpy
import time
from time import sleep
import re
import random
import math
import hashlib
from urllib.parse import unquote
这是我尝试在第二个文件(main.py)中导入的内容:
from flask import Flask, jsonify, request
import snsr
import os
import binascii
import hashlib
这是我requirements.txt文件:
Flask==2.0.2
gunicorn==20.1.0
requests
numpy
regex
python-math
urllib3
os-win
这是我的docker:
# Use the official lightweight Python image.
# https://hub.docker.com/_/python
FROM python:3.10-slim
# Allow statements and log messages to immediately appear in the Knative logs
ENV PYTHONUNBUFFERED True
# Copy local code to the container image.
ENV APP_HOME /app
WORKDIR $APP_HOME
COPY . ./
# Install production dependencies.
RUN pip install -r requirements.txt
# Run the web service on container startup. Here we use the gunicorn
# webserver, with one worker process and 8 threads.
# For environments with multiple CPU cores, increase the number of workers
# to be equal to the cores available.
# Timeout is set to 0 to disable the timeouts of the workers to allow Cloud Run to handle instance scaling.
CMD exec gunicorn --bind :$PORT --workers 1 --threads 8 --timeout 0 main:app
答: 暂无答案
评论
non-zero
pip install -r requirements.txt
Dockerfile
docker
podman
docker build --tag=deleteme --file=./Dockerfile .
os-win
是问题所在。