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

import errors when invoking flask db init #435

Closed
Jobenas opened this issue Sep 20, 2021 · 3 comments
Closed

import errors when invoking flask db init #435

Jobenas opened this issue Sep 20, 2021 · 3 comments
Labels

Comments

@Jobenas
Copy link

Jobenas commented Sep 20, 2021

Hi:

I'm currently writing a simple flask app and wanted to try the app with a sqlite database. After creating the models and all the boilerplate for the database, I run the command:

flask db init

which throws the following error:

Traceback (most recent call last):
  File "/home/jobenas/.local/lib/python3.8/site-packages/flask/cli.py", line 256, in locate_app
    __import__(module_name)
  File "/mnt/c/Users/joben/personal_dev/Python/pucp_provision_system/server.py", line 15, in <module>
    from base.routes import login_manager
  File "/mnt/c/Users/joben/personal_dev/Python/pucp_provision_system/base/routes.py", line 9, in <module>
    from base.forms import LoginForm, RegisterUserForm, RegisterUserFormAdmin
  File "/mnt/c/Users/joben/personal_dev/Python/pucp_provision_system/base/forms.py", line 1, in <module>
    from flask_wtf import FlaskForm
  File "/home/jobenas/.local/lib/python3.8/site-packages/flask_wtf/__init__.py", line 17, in <module>
    from .recaptcha import *
  File "/home/jobenas/.local/lib/python3.8/site-packages/flask_wtf/recaptcha/__init__.py", line 2, in <module>
    from .fields import *
  File "/home/jobenas/.local/lib/python3.8/site-packages/flask_wtf/recaptcha/fields.py", line 3, in <module>
    from . import widgets
  File "/home/jobenas/.local/lib/python3.8/site-packages/flask_wtf/recaptcha/widgets.py", line 5, in <module>
    from werkzeug import url_encode
ImportError: cannot import name 'url_encode' from 'werkzeug' (/home/jobenas/.local/lib/python3.8/site-packages/werkzeug/__init__.py)

I'm currently running:
Werkzeug version 2.0.1
Flask-Migrate version 3.1.0
Flask-SQLAlchemy version 2.5.1
Flask version 2.0.1

I'm not sure if there's any other dependency needed to run this. Thanks in advance for any pointers.

PS: Sorry for the horrible formatting, I'm not very knowledgeable with markdown.

@miguelgrinberg
Copy link
Owner

This error is unrelated, it is in the Flask-WTF package. My guess is that you need to upgrade it to work well with Flask and Werkzeug version 2.

@Jobenas
Copy link
Author

Jobenas commented Sep 20, 2021

Hi Miguel, thanks for the reply, I'm on version 2.3.3 of WTForms and version 0.15.1 Flask-WTF package, which I understand is the latest version. Is there any version that's recommended for werkzeug version 2?

@miguelgrinberg
Copy link
Owner

You need to check your versions, something isn't right in what you are reporting. The line that is giving you the error is different in the current release of Flask-WTF (here). Try reinstalling Flask-WTF.

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

No branches or pull requests

2 participants