tortuga445
tortuga445

Reputation: 35

No name 'routes' in module 'app'pylint(no-name-in-module)

I have a file "init.py" inside have this code

from flask import Flask 
app = Flask(__name__) 
from app import routes 

And in a "routes.py" i have this code

from app import app
@app.route('/')
@app.route('/index')
def index():
    user = 'Cala'
return render_template('index.html', user=user) 

In the first file in the 3 line say

No name 'routes' in module 'app' pylint(no-name-in-module)

And in the second file in the firts line say

Unable to import 'app' pylint(import-error)

Somebody know what is the problem?, is the fisrt time i do it this is probably is simple or all is wrong. Thanks

Upvotes: 0

Views: 1963

Answers (1)

Alexey
Alexey

Reputation: 178

The problem in your case is that you didn't put both your files in app directory, since you are using __init__.py file. When doing from app import app it searches for an app directory or app.py file, if directory is not found. If directory is found, it searches for app variable inside __init__.py file.

Upvotes: 1

Related Questions