问题描述
我最近使用pip安装了Flask-WTF以及wtforms和wtf.我只是不知道如何在我的python文件__init__.py
中导入其中的任何一个.我试过了:
I recently installed Flask-WTF and wtforms and wtf, using pip. I just don't know how to import anyone of these in my python file __init__.py
. I tried:
from wtforms import Form
from Flask_WTF import Form
from wtf import Form
from flask_wtf import Form
from flask_wtforms import Form
等...
大多数烧瓶文档都告诉我使用from wtforms import Form
...,但是它显示了ImportError: No module named wtforms
.似乎您导入WTF的方式(或被称为)已不再相同.有人知道如何导入WTF吗?谢谢!
Most of the Flask Documentations tell me to use from wtforms import Form
... But it shows ImportError: No module named wtforms
. It seems like the way you have to import WTF (or however it is called) is not the same anymore. Does anyone know how to import WTF? Thank you!
更新:
我在python site-packages
目录usr/lib/python2.7/site-packages
中搜索了Flask-WTF,发现没有任何东西引用Flask-WTF.在运行pip install Flask-WTF
或pip install wtf
或pip install wtforms
之后,甚至还没有安装Flask-WTF,即使终端返回了它.有人知道为什么吗?
I searched for Flask-WTF in the python site-packages
directory, usr/lib/python2.7/site-packages
and found out that there is nothing refering to Flask-WTF. It appears that Flask-WTF was not even installed after running pip install Flask-WTF
or pip install wtf
or pip install wtforms
, even tho the terminal returned that it was. Does anyone know why?
推荐答案
我注意到pip
没有安装Flask-WTF,所以我用easy_install
做到了,它可以工作,并且我可以导入想要的东西导入.
I noticed that pip
doesn't install Flask-WTF, so I did it with easy_install
, it worked, and I could import what I wanted to import.
这篇关于如何导入Flask-WTF?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!