0

我对 gcloud 有点陌生,我不知道如何解决这个错误:(

当我尝试将我的 API 部署到云运行时,我收到以下错误消息:

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

这是我的码头工人:

# 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
4

0 回答 0