[英]from google.cloud import bigquery ModuleNotFoundError: No module named 'google'
After following the basic Google cloud run tutorial ( https://cloud.google.com/run/docs/quickstarts/build-and-deploy ), 遵循基本的Google云运行教程( https://cloud.google.com/run/docs/quickstarts/build-and-deploy )之后,
I have been trying to deploy to something a bit more complex but without success.. 我一直在尝试将其部署到更复杂的地方,但是没有成功。
My app.py starts with those imports: 我的app.py从这些导入开始:
import os
import uuid
import requests
import json
from google.cloud import bigquery
from flask import Flask
But when I try to run it I get the following logs: 但是,当我尝试运行它时,会得到以下日志:
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker
worker.init_process()
File "/usr/local/lib/python3.7/site-packages/gunicorn/workers/gthread.py", line 104, in init_process
super(ThreadWorker, self).init_process()
File "/usr/local/lib/python3.7/site-packages/gunicorn/workers/base.py", line 129, in init_process
self.load_wsgi()
File "/usr/local/lib/python3.7/site-packages/gunicorn/workers/base.py", line 138, in load_wsgi
self.wsgi = self.app.wsgi()
File "/usr/local/lib/python3.7/site-packages/gunicorn/app/base.py", line 67, in wsgi
self.callable = self.load()
File "/usr/local/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 52, in load
return self.load_wsgiapp()
File "/usr/local/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 41, in load_wsgiapp
return util.import_app(self.app_uri)
File "/usr/local/lib/python3.7/site-packages/gunicorn/util.py", line 350, in import_app
__import__(module)
File "/app/app.py", line 6, in <module>
from google.cloud import bigquery
ModuleNotFoundError: No module named 'google'
Dockerfile looks like this: Dockerfile看起来像这样:
# Use the official Python image.
# https://hub.docker.com/_/python
FROM python:3.7-slim
# Copy local code to the container image.
ENV APP_HOME /app
WORKDIR $APP_HOME
COPY . ./
# Install production dependencies.
RUN pip install Flask gunicorn requests uuid google
# 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.
CMD exec gunicorn --bind :$PORT --workers 1 --threads 8 app:app
看来要为BigQuery安装的正确python模块是google-cloud-bigquery
RUN pip install Flask gunicorn requests uuid google-cloud-bigquery
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.