简体   繁体   English

zsh:找不到命令:烧瓶

[英]zsh: command not found: flask

I am unable to proceed with the command flask db init我无法继续执行命令flask db init

from flask import Flask, render_template, request, redirect, url_for, jsonify
from flask_sqlalchemy import SQLAlchemy
import sys
from flask_migrate import Migrate
from flask_cli import FlaskCLI
from flask_cli import FlaskGroup

app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'postgres://postgres@localhost:5432/todoapp'
db = SQLAlchemy(app)

migrate = Migrate(app, db)

class Todo(db.Model):
    __tablename__ = 'todos'
    id = db.Column(db.Integer, primary_key=True)
    description = db.Column(db.String(), nullable=False)

    def __repr__(self):
        return f'<Todo {self.id} {self.description}>'

db.create_all() 

@app.route('/')
def index():
    return render_template('index.html', data=Todo.query.all())

if __name__ == '__main__':
    app.run(debug=True)  

When I put the command pip3 list, this is result below:当我输入命令 pip3 list 时,结果如下:

Package            Version
------------------ -------
alembic            1.3.3  
appnope            0.1.0  
astroid            2.2.5  
attrs              19.1.0 
backcall           0.1.0  
bleach             3.1.0  
Click              7.0    
decorator          4.4.0  
defusedxml         0.6.0  
entrypoints        0.3    
Flask              1.1.1  
Flask-Alembic      2.0.1  
Flask-CLI          0.4.0  
Flask-Migrate      2.5.2  
Flask-MySQLdb      0.2.0  
Flask-SQLAlchemy   2.4.1  
Flask-WTF          0.14.2 
ipykernel          5.1.2  
ipython            7.8.0  
ipython-genutils   0.2.0  
ipywidgets         7.5.1  
isort              4.3.21 
itsdangerous       1.1.0  
jedi               0.15.1 
Jinja2             2.10.1 
jsonschema         3.0.2  
jupyter            1.0.0  
jupyter-client     5.3.1  
jupyter-console    6.0.0  
jupyter-core       4.5.0  
lazy-object-proxy  1.4.2  
Mako               1.1.1  
MarkupSafe         1.1.1  
mccabe             0.6.1  
mistune            0.8.4  
mysql              0.0.2  
mysqlclient        1.4.6  
nbconvert          5.6.0  
nbformat           4.4.0  
notebook           6.0.1  
pandocfilters      1.4.2  
parso              0.5.1  
passlib            1.7.2  
pexpect            4.7.0  
pickleshare        0.7.5  
pip                20.0.2 
prometheus-client  0.7.1  
prompt-toolkit     2.0.9  
ptyprocess         0.6.0  
pygame             1.9.6  
Pygments           2.4.2  
pylint             2.3.1  
pyrsistent         0.15.4 
python-dateutil    2.8.0  
python-editor      1.0.4  
pyzmq              18.1.0 
qtconsole          4.5.4  
Send2Trash         1.5.0  
setuptools         45.1.0 
six                1.12.0 
SQLAlchemy         1.3.13 
terminado          0.8.2  
testpath           0.4.2  
tornado            6.0.3  
traitlets          4.3.2  
typed-ast          1.4.0  
uWSGI              2.0.18 
wcwidth            0.1.7  
webencodings       0.5.1  
Werkzeug           0.16.0 
wheel              0.33.1 
widgetsnbextension 3.5.1  
wrapt              1.11.2 
WTForms            2.2.1 

And my python library site packages path is我的python库站点包路径是

/Users/kurosaki/Library/Python/3.8/lib/python/site-packages/

I have already tried python3 -m flask run which resulted in我已经尝试过 python3 -m flask run导致

pkg_resources.DistributionNotFound: The 'alembic>=0.7' distribution was not found and is required by the application pkg_resources.DistributionNotFound:未找到“alembic>=0.7”发行版,应用程序需要该发行版

I need help to proceed with flask command on the terminal.我需要帮助才能在终端上执行flask 命令。

I have the answer even if I am using python 3.8 or python 3.7即使我使用的是 python 3.8 或 python 3.7,我也有答案

I have to use我必须使用

python3 -m flask db init

so, in every flask command, I have to put所以,在每个烧瓶命令中,我必须把

python3 -m蟒蛇3 -m

before it在它之前

You may not be running an instance of your flask application.您可能没有运行您的 Flask 应用程序的实例。 It may require this first它可能首先需要这个

export FLASK_APP=app.py

Once you have a flask application instance, perform your database initialisations一旦你有一个烧瓶应用程序实例,执行你的数据库初始化

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM