honmaple / maple-blog

a blog website based on flask
GNU General Public License v3.0
119 stars 49 forks source link

初始化数据库时导入错误 #9

Open evertears opened 4 years ago

evertears commented 4 years ago

ImportError: cannot import name 'url_encode'

在执行初始化数据库时发生导入错误,请问如何解决?

tom@Evertears:~/maple-blog$ python3 runserver.py db init Traceback (most recent call last): File "runserver.py", line 25, in from maple import create_app File "/home/tom/maple-blog/maple/init.py", line 11, in from maple import extension, router, jinja, admin, alias, api File "/home/tom/maple-blog/maple/extension/init.py", line 15, in from flask_wtf.csrf import CSRFProtect File "/home/tom/.local/lib/python3.5/site-packages/flask_wtf/init.py", line 17, in from .recaptcha import File "/home/tom/.local/lib/python3.5/site-packages/flask_wtf/recaptcha/init.py", line 2, in from .fields import File "/home/tom/.local/lib/python3.5/site-packages/flask_wtf/recaptcha/fields.py", line 3, in from . import widgets File "/home/tom/.local/lib/python3.5/site-packages/flask_wtf/recaptcha/widgets.py", line 5, in from werkzeug import url_encode ImportError: cannot import name 'url_encode'

honmaple commented 4 years ago

请确认flask_wtf的版本是否是0.14.2

evertears commented 4 years ago

确实是这样,已经解决,谢谢大神。

evertears commented 4 years ago

之前安装了flask_wtf的0.14.2版本就正常运行了,现在换了新的环境安装之后依然报同样的错误。该怎么解决呢?

tom@Evertears:~/flask_code/maple-blog$ python3 runserver.py db init
Traceback (most recent call last):
  File "runserver.py", line 25, in <module>
    from maple import create_app
  File "/home/tom/flask_code/maple-blog/maple/__init__.py", line 11, in <module>
    from maple import extension, router, jinja, admin, alias, api
  File "/home/tom/flask_code/maple-blog/maple/extension/__init__.py", line 15, in <module>
    from flask_wtf.csrf import CSRFProtect
  File "/home/tom/.local/lib/python3.6/site-packages/flask_wtf/__init__.py", line 17, in <module>
    from .recaptcha import *
  File "/home/tom/.local/lib/python3.6/site-packages/flask_wtf/recaptcha/__init__.py", line 2, in <module>
    from .fields import *
  File "/home/tom/.local/lib/python3.6/site-packages/flask_wtf/recaptcha/fields.py", line 3, in <module>
    from . import widgets
  File "/home/tom/.local/lib/python3.6/site-packages/flask_wtf/recaptcha/widgets.py", line 5, in <module>
    from werkzeug import url_encode
ImportError: cannot import name 'url_encode'