【问题标题】:ModuleNotFoundError: No module named 'flask_dance'" on Google Cloud runModuleNotFoundError:谷歌云上没有名为“flask_dance”的模块运行
【发布时间】:2020-03-09 07:03:38
【问题描述】:

我已经构建了一个烧瓶应用程序并将其部署在 Google Cloud 上,并且在构建和部署时收到以下错误:

ModuleNotFoundError: No module named 'flask_dance'"

我是这样使用库的:

from flask_dance.consumer import oauth_authorized
from flask_dance.contrib.google import make_google_blueprint, google

应用程序在 localhost 上运行良好,构建和部署不报告任何错误(只是当我尝试通过给定 url 访问部署时,我在 GCP 控制台中收到此错误。

我的 requirements.txt 看起来像:

blinker==1.4
CacheControl==0.12.6
cachetools==4.0.0
certifi==2019.11.28
cffi==1.14.0
chardet==3.0.4
Click==7.0
cryptography==2.8
firebase-admin==4.0.0
Flask==1.1.1
Flask-Dance==3.0.0
Flask-Login==0.5.0
Flask-WTF==0.14.3
google-api-core==1.16.0
google-api-python-client==1.7.11
google-auth==1.11.2
google-auth-httplib2==0.0.3
google-cloud-core==1.3.0
google-cloud-firestore==1.6.2
google-cloud-storage==1.26.0
google-resumable-media==0.5.0
googleapis-common-protos==1.51.0
grpcio==1.27.2
httplib2==0.17.0
idna==2.9
itsdangerous==1.1.0
Jinja2==2.11.1
MarkupSafe==1.1.1
msgpack==1.0.0
oauthlib==3.1.0
protobuf==3.11.3
pyasn1==0.4.8
pyasn1-modules==0.2.8
pycparser==2.20
pyOpenSSL==19.1.0
pytz==2019.3
requests==2.23.0
requests-oauthlib==1.3.0
rsa==4.0
six==1.14.0
spoonacular==3.0
uritemplate==3.0.1
urllib3==1.25.8
URLObject==2.4.3
Werkzeug==1.0.0
WTForms==2.2.1

flask_dance 出现在那里(同样,在本地运行良好)。

我不知道为什么会收到模块导入错误。任何帮助找出根本原因将不胜感激。

【问题讨论】:

  • 哪个运行时/环境?
  • 您是否指定在 Dockerfile 中安装该模块?例如。 RUN pip install Flask-DanceRUN pip install -r requirements.txt
  • @DanCornilescu python3
  • @DenisT。是的,这行得通!谢谢你。添加一行将其复制到 docker 容器中,然后运行 ​​pip install。干杯
  • 很高兴能为您提供帮助。我在这个线程中添加了一个答案。既然问题已经解决,请接受它以便在社区中获得更好的知名度

标签: python google-app-engine google-cloud-platform oauth flask-dance


【解决方案1】:

确保在 Dockerfile 中指定安装该模块:

例如

# Install production dependencies.
RUN pip install Flask-Dance

或者

# Install production dependencies.
RUN pip install -r requirements.txt

查看containerizing该应用程序。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-09-03
    • 2019-03-28
    • 1970-01-01
    • 2022-01-16
    • 2022-01-07
    相关资源
    最近更新 更多