Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImportError: No module named flask_basicauth #13

Open
oceanpad opened this issue Jan 10, 2018 · 4 comments
Open

ImportError: No module named flask_basicauth #13

oceanpad opened this issue Jan 10, 2018 · 4 comments

Comments

@oceanpad
Copy link

I had installed Flask-BasicAuth use:

sudo pip install Flask-BasicAuth

My code looks like this:

from flask import Flask, render_template
from flask_basicauth import BasicAuth

app = Flask(__name__)

app.config['BASIC_AUTH_USERNAME'] = 'john'
app.config['BASIC_AUTH_PASSWORD'] = 'matrix'
app.config['BASIC_AUTH_FORCE'] = True

basic_auth = BasicAuth(app)

@app.route('/')
@basic_auth.required
def secret_view():
    return render_template('404.html')

if __name__ == '__main__':
  app.run(host='0.0.0.0', port=3000)

But when I run it, The error is.

Traceback (most recent call last):
  File "run.py", line 2, in <module>
    from flask_basicauth import BasicAuth
ImportError: No module named flask_basicauth
@cartacioS
Copy link

Hey did you find a fix for this?

@vackosar
Copy link

@cartacioS why do you use app.config['BASIC_AUTH_FORCE'] = True and at the same time @basic_auth.required?

For me if I set the force option then I don't need to use required decorator.

@rjkunde
Copy link

rjkunde commented Nov 22, 2019

Just ran into this. My application was written in python3, but I experienced the error after: sudo python app.py, which ran it with python2. I made sure that basicAuth was installed using: sudo pip3 install Flask-BasicAuth.

@raquelpaiva
Copy link

Hey guys, did you get solved this problem? i had the same problem here " raceback (most recent call last):
File "main.py", line 2, in
from flask_basicauth import BasicAuth
ModuleNotFoundError: No module named 'flask_basicauth'"
ANd i did install "sudo pip3 install Flask-BasicAuth" but, when i call "python main.py" i had the same problem =(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants