Answer the question
In order to leave comments, you need to log in
python-flask variable not being imported?
Good afternoon, there was a problem, I created a package, in __init__ I wrote
import telebot
from flask import Flask, session
from bot.db import *
app = Flask(__name__)
app.secret_key = 'ddddd'
if __name__ == '__main__':
app.run(debug = True)
from flaskext.mysql import MySQL
from bot import app
app.config['MYSQL_DATABASE_USER'] = 'lie'
app.config['MYSQL_DATABASE_PASSWORD'] = 'zx23ww'
app.config['MYSQL_DATABASE_DB'] = 'telebot'
app.config['MYSQL_DATABASE_HOST'] = 'localhost'
mysql = MySQL(app)
connect = mysql.connect()
* Serving Flask app "bot"
* Environment: production
WARNING: This is a development server. Do not use it in a production deployment.
Use a production WSGI server instead.
* Debug mode: off
Usage: flask run [OPTIONS]
Error: While importing "bot", an ImportError was raised:
Traceback (most recent call last):
File "/home/lietry/sova/callback/venv/lib/python3.6/site-packages/flask/cli.py", line 236, in locate_app
__import__(module_name)
File "/home/lietry/sova/callback/bot/__init__.py", line 3, in <module>
from bot.db import *
File "/home/lietry/sova/callback/bot/db.py", line 2, in <module>
from bot import app
ImportError: cannot import name 'app'
Answer the question
In order to leave comments, you need to log in
You import db from bot, and bot from db. Crossimports are not allowed. Either import one thing, or put all the variables for sharing in a separate package
position: absolute for the text + position: relative for the parent to help you
and please post it on jsfiddle / codepen next time, it's hard to navigate by screenshots
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question