ModuleNotFoundError:没有名为'fire'的模块

时间:2018-01-21 17:51:15

标签: python flask

当我尝试从同一目录中的另一个python文件导入函数时,我收到错误。当我删除导入时,应用程序运行正常。任何人都可以告诉我为什么我收到以下导入错误?

我应该补充一点,我正在运行应用程序运行start.sh文件

start.sh

source venv/bin/activate
export FLASK_APP=myapp.py
flask run

ModuleNotFoundError:没有名为'fire'的模块

routes.py

from flask import render_template
from app import app
from fire import fire

@app.route('/')
@app.route('/index')
def index():
    user = {'username': 'Miguelll'}
    posts = [
        {
            'author': {'username': 'John'},
            'body': 'Beautiful day in Portland!'
        },
        {
            'author': {'username': 'Susan'},
            'body': 'The Avengerss movie was so cool!'
        }
    ]
    print(fire())
    return render_template('index.html', title='Home', user=user, posts=posts)

fire.py

import pyrebase

config = {
  "apiKey": "SNIP",
  "authDomain": "SNIP.firebaseapp.com",
  "databaseURL": "SNIP",
  "storageBucket": "SNIP.appspot.com",
  "serviceAccount": "SNIP.json"
}

firebase = pyrebase.initialize_app(config)

def fire():
  auth = firebase.auth()
  #authenticate a user
  user = auth.sign_in_with_email_and_password("SNIP@SNIP.com", "SNIPSNIPSNIP$")

  all_agents = db.child("items").get(user['idToken']).val()

  print(all_agents)

我的目录结构(为什么这张图片太大了): enter image description here

1 个答案:

答案 0 :(得分:0)

我需要将导入更改为

from app.fire import fire