无法在Gcloud上部署Flask应用:ModuleNotFoundError:没有名为“ flask_bcrypt”的模块

时间:2019-11-18 01:24:07

标签: python flask gcloud bcrypt

使用以下方式部署我的gcloud应用程序时出现以下错误: gcloud app deploy app.yaml 并且即使构建成功,我也会在网站上看到“错误:服务器错误”。 日志内容如下:

 File "/env/lib/python3.7/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker      worker.init_process()    
File "/env/lib/python3.7/site-packages/gunicorn/workers/base.py", line 129, in init_process      self.load_wsgi()   
    File "/env/lib/python3.7/site-packages/gunicorn/workers/base.py", line 138, in load_wsgi      
self.wsgi =  self.app.wsgi()    
File "/env/lib/python3.7/site-packages/gunicorn/app/base.py", line 67, in wsgi      
self.callable = self.load()    
File "/env/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 52, in load      return self.load_wsgiapp()    
File "/env/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 41, in load_wsgiapp      return util.import_app(self.app_uri)    
File "/env/lib/python3.7/site-packages/gunicorn/util.py", line 350, in import_app      __import__(module)    File "/srv/run.py", line 1, in <module>      from flask_website import app    File "/srv/flask_website/__init__.py", line 3, in <module> 
 from flask_bcrypt import Bcrypt  ModuleNotFoundError: No module named 'flask_bcrypt'
2019-11-17 20:49:10 default[20191117t124759]  [2019-11-17 20:49:10 +0000] [14] [INFO] Worker exiting (pid: 14)
2019-11-17 20:49:10 default[20191117t124759]  [2019-11-17 20:49:10 +0000] [7] [INFO] Shutting down: Master
2019-11-17 20:49:10 default[20191117t124759]  [2019-11-17 20:49:10 +0000] [7] [INFO] Reason: Worker failed to boot.
2019-11-17 21:02:58 default[20191117t125833]  "GET / HTTP/1.1" 500
2019-11-17 21:02:59 default[20191117t125833]  /bin/sh: 1: exec: gunicorn: not found

我不明白“ Flask-bcrypt”错误,因为它显然已安装在环境中。 __ init __。py

from flask import Flask
from flask_sqlalchemy import SQLAlchemy
from flask_login import LoginManager
from flask_bcrypt import Bcrypt

app = Flask(__name__, template_folder='templates')
app.config['SECRET_KEY'] = 'nca6e08946d0da1c34c67c850b5db5a29'
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///site.db'
db = SQLAlchemy(app)
bcrypt = Bcrypt(app)

login_manager = LoginManager(app)
login_manager.login_view = 'login'
login_manager.login_message_category = 'info'

from flask_website import routes

结构

│   .gcloudignore
│   app.yaml
│   requirements.txt
│   run.py
│
├───flask_website
│   │   forms.py
│   │   models.py
│   │   routes.py
│   │   site.db
│   │   __init__.py
│   │
│   ├───py_bcrypt
│   │       bcrypt.py
│   │       blowfish.py
│   │       readme
│   │       simple_test.py
│   │       test.py
│   │       __init__.py
│   │
│   ├───static
│   │   │   main.css
│   │   │
│   │   └───profile_pictures
│   │           04f72388ee1604a9.png
│   │           a1d05ebef869b942.jpg
│   │           default.png
│   │           default2.jpg
│   │
│   └───templates
│           about.html
│           account.html
│           create_post.html
│           home.html
│           layout.html
│           login.html
│           register.html
│
└───__pycache__
        run.cpython-37.pyc

Requirements.txt

argh==0.26.2
asn1crypto==1.2.0
backcall==0.1.0
bcrypt==3.1.7
boto3==1.10.9
botocore==1.13.9
cachetools==3.1.1
certifi==2019.9.11
cffi==1.13.2
chardet==3.0.4
Click==7.0
colorama==0.3.9
cryptography==2.7
decorator==4.4.1
docutils==0.14
Flask==1.1.1
Flask-Bcrypt==0.7.1
Flask-Login==0.4.1
Flask-SQLAlchemy==2.4.0
Flask-WTF==0.14.2
freetype-py==2.1.0.post1
idna==2.8
ipython==7.8.0
ipython-genutils==0.2.0
itsdangerous==1.1.0
jedi==0.15.1
Jinja2==2.10.3
jmespath==0.9.4
MarkupSafe==1.1.1
mo==0.3.0
olefile==0.46
parso==0.5.1
pickleshare==0.7.5
Pillow==6.2.1
prompt-toolkit==2.0.10
protobuf==3.10.0
pyasn1==0.4.6
pyasn1-modules==0.2.7
pycparser==2.19
Pygments==2.4.2
PyOpenGL==3.1.0
pyOpenSSL==19.0.0
PyQt5-sip==4.19.14
pyqt5-tools==5.11.3.1.4
PySocks==1.7.1
python-dateutil==2.8.0
python-dotenv==0.10.1
pytz==2019.3
requests==2.22.0
rsa==3.4.2
s3transfer==0.2.1
sip==4.19.8
six==1.13.0
SQLAlchemy==1.3.11
style==1.1.0
toml==0.10.0
traitlets==4.3.3
update==0.0.1
urllib3==1.25.6
wcwidth==0.1.7
Werkzeug==0.16.0
win-inet-pton==1.1.0
wincertstore==0.2
WTForms==2.2.1

我之前可以使用它,但是我不确定发生了什么变化,也许添加了flask-bcrypt模块?感谢您的帮助。

1 个答案:

答案 0 :(得分:1)

我在自己的环境中安装了Gunicorn,它开始工作了。