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: cannot import name 'TextField' from 'wtforms' #206

Closed
jwarzinik opened this issue Nov 10, 2021 · 18 comments
Closed

ImportError: cannot import name 'TextField' from 'wtforms' #206

jwarzinik opened this issue Nov 10, 2021 · 18 comments

Comments

@jwarzinik
Copy link

jwarzinik commented Nov 10, 2021

Fresh install of Ubunto 20.04 and I have FTS server running and ATAK can connect, but can't get UI running --> error code below. Can some assist please?

freetakserver@freetakserver:~ $ sudo python3 /usr/local/lib/python3.8/dist-packages/FreeTAKServer-UI/run.py
[sudo] password for freetakserver:
Traceback (most recent call last):
File "/usr/local/lib/python3.8/dist-packages/FreeTAKServer-UI/run.py", line 57, in
app = create_app( app_config )
File "/usr/local/lib/python3.8/dist-packages/FreeTAKServer-UI/app/init.py", line 93, in create_app
register_blueprints(app)
File "/usr/local/lib/python3.8/dist-packages/FreeTAKServer-UI/app/init.py", line 25, in register_blueprints
module = import_module('app.{}.routes'.format(module_name))
File "/usr/lib/python3.8/importlib/init.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 1014, in _gcd_import
File "", line 991, in _find_and_load
File "", line 975, in _find_and_load_unlocked
File "", line 671, in _load_unlocked
File "", line 848, in exec_module
File "", line 219, in _call_with_frames_removed
File "/usr/local/lib/python3.8/dist-packages/FreeTAKServer-UI/app/base/routes.py", line 17, in
from app.base.forms import LoginForm, CreateAccountForm
File "/usr/local/lib/python3.8/dist-packages/FreeTAKServer-UI/app/base/forms.py", line 8, in
from wtforms import TextField, PasswordField
ImportError: cannot import name 'TextField' from 'wtforms' (/usr/local/lib/python3.8/dist-packages/wtforms/init.py)
freetakserver@freetakserver:~$

@mgibb00271
Copy link

I observed the following when attempting to install on Ubuntu 20.04. I can connect with ATAK on TCP unencrypted 8087.

Traceback (most recent call last):
File "/usr/local/lib/python3.8/dist-packages/FreeTAKServer-UI/run.py", line 57, in
app = create_app( app_config )
File "/usr/local/lib/python3.8/dist-packages/FreeTAKServer-UI/app/init.py", line 93, in create_app
register_blueprints(app)
File "/usr/local/lib/python3.8/dist-packages/FreeTAKServer-UI/app/init.py", line 25, in register_blueprints
module = import_module('app.{}.routes'.format(module_name))
File "/usr/lib/python3.8/importlib/init.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 1014, in _gcd_import
File "", line 991, in _find_and_load
File "", line 975, in _find_and_load_unlocked
File "", line 671, in _load_unlocked
File "", line 848, in exec_module
File "", line 219, in _call_with_frames_removed
File "/usr/local/lib/python3.8/dist-packages/FreeTAKServer-UI/app/base/routes.py", line 17, in
from app.base.forms import LoginForm, CreateAccountForm
File "/usr/local/lib/python3.8/dist-packages/FreeTAKServer-UI/app/base/forms.py", line 8, in
from wtforms import TextField, PasswordField
ImportError: cannot import name 'TextField' from 'wtforms' (/usr/local/lib/python3.8/dist-packages/wtforms/init.py)

Mike

@OzInFl
Copy link

OzInFl commented Nov 12, 2021

I was able to correct this by editing /usr/local/lib/python3.8/dist-packages/FreeTAKServer-UI/app/base/forms.py
replace all "TextField" values with "StringField"
now the UI comes up, but getting connection error message at the bottom, i may have caused it by the config changes i made trying to test, so interesting to see what you get..

@jwarzinik
Copy link
Author

Can you post your working forms.py I made the changes and the GUI starts now but I can't login. This is a new install and the default admin and password doesn't work. I did noticed that the last password line in the UpdateAccountForm was using TextField and all other lines that work with password was PasswordField... I tried it both ways and still couldn't login. I did this same install without any issues October 30 and didn't run into these issues so odd to run into this road block now ...some sort of bug has been introduced.

@tetarotetaro
Copy link

Same issue on my install. Replacing "TextField" didn't solve it. When installed couple of months ago, there were no problems.
Is there any way to install any previous version instead? I am using fresh install of Ubuntu 20.04.3 LTS.

@HoneyBadgerActual
Copy link

HoneyBadgerActual commented Nov 18, 2021

I was able to correct this by editing /usr/local/lib/python3.8/dist-packages/FreeTAKServer-UI/app/base/forms.py replace all "TextField" values with "StringField" now the UI comes up, but getting connection error message at the bottom, i may have caused it by the config changes i made trying to test, so interesting to see what you get..

this also workwd for me, thats part of how i got my server to run. i got the UI up, and was goi g to log in and make alterations to the settings in the UI for ease of use, but i cant actually get logged in, because my server apparently didnt install correctly, something about my pathlib. im going to edit my recent ticket and add some more info now that I'm more awake and have a vetter idea of why my UI was working but the server wasn't.

now i gotta figure out the pathlib issue and why its not installing the server correctly, its also had issues i staing some tools as well.

My issue #211

@jwarzinik
Copy link
Author

@OzInFl - any reason why on a new install of server and GUI that admin and password would not get me into the GUI? Not sure how to troubleshoot this issue to get me in and going.

@OzInFl
Copy link

OzInFl commented Nov 18, 2021

Im not sure, I am able to login with 'admin' and 'password' however now in the GUI, which looks nice, i get the 'Sorry, there seems to be an issue with the connection!' that pops up every few seconds.. still more to debug..

@jwarzinik
Copy link
Author

Since I have the "working install" from Oct on my other VM. Am I able to simply copy all the /disto-packages/ folders related to the IU over to my new server and would it work?

@maglore9900
Copy link

Same issue on CentOS7, same conditions. Watching for solution.

@tsvtx
Copy link

tsvtx commented Nov 22, 2021

downgrade wtforms from 3.0 to 2.3.3. They deprecated TextField and replaced with StringField in 3.0 so the latest will break until the python files are updated to support String vs Text.

As a workaround run the following to remove 3.0 and replace with 2.3.3. the UI will launch after completed.

sudo pip3 install WTForms==2.3.3

@brothercorvo
Copy link
Collaborator

thank you @tsvtx, this is the solution for now

@jwarzinik
Copy link
Author

jwarzinik commented Nov 22, 2021

I wouldn't consider this closed just yet.... Have you updated the install back to using WTForm 2.3.3? I tied the above commend and then also changed my forms.py back to default and now UI will not start saying it can't import TextField. Should I uninstall UI and reinstall?

@tsvtx
Copy link

tsvtx commented Nov 22, 2021

That has no bearing on the version of forms you have installed. If you're still seeing it, you need to check the active version.

Execute the following: 'sudo pip3 show wtforms'

You should see:

Name: WTForms
Version: 2.3.3
Summary: A flexible forms validation and rendering library for Python web development.
Home-page: https://wtforms.readthedocs.io/
Author: None
Author-email: None
License: BSD-3-Clause
Location: /usr/local/lib/python3.8/dist-packages
Requires: MarkupSafe
Required-by: Flask-WTF

If it still shows as 3.0, maybe your system is being ornery and needs to have it spelled out as the auto replace isn't working right...

sudo pip3 uninstall wtforms
sudo pip3 install WTForms==2.3.3

@tetarotetaro
Copy link

Had the same issue even after rolling back to 2.3.3.
I stayed with 2.3. and finally made it run by also changing TextField do StringField in forms.py.
Everything started and is running correctly.

@jwarzinik
Copy link
Author

That did the trick, I had to run both uninstalls sudo pip3 uninstall wtforms and sudo pip3 uninstall wtforms==2.3.3 before running the install sudo pip3 install wtforms==2.3.3 to get sudo pip3 show wtforms to show the correct v2.3.3 of wtforms.

@brothercorvo
Copy link
Collaborator

I wouldn't consider this closed just yet.... Have you updated the install back to using WTForm 2.3.3? I tied the above commend and then also changed my forms.py back to default and now UI will not start saying it can't import TextField. Should I uninstall UI and reinstall?

the correct version of wtforms is part of the requirements. However if you have a machine with higher version I would not deinstall and re-install it

@brothercorvo brothercorvo reopened this Nov 23, 2021
@godaminski
Copy link

I was able to correct this by editing /usr/local/lib/python3.8/dist-packages/FreeTAKServer-UI/app/base/forms.py replace all "TextField" values with "StringField" now the UI comes up, but getting connection error message at the bottom, i may have caused it by the config changes i made trying to test, so interesting to see what you get..

This worked for me as well.

naman108 added a commit that referenced this issue Dec 12, 2021
updated wtforms dependencies version to address issue #206
@brothercorvo
Copy link
Collaborator

CLosed because we have updated the dependencies

ianychoi added a commit to ianychoi/flask-mongodb that referenced this issue May 15, 2022
To prevent error
"ImportError: cannot import name 'TextField' from 'wtforms'"

More details: FreeTAKTeam/FreeTakServer#206
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

9 participants