I have email_validator installed but I am getting an error message saying it is not installed. Does it have to be installed in my project folder? Or can it be in the main site-packages folder? When I run my program I get this error message:
Exception: Install 'email_validator' for email validation support
I can see that I have it installed in the main site-packages python3 folder, but when I run
pip install email_validator
from within my project folder site-packages folder the terminal prints this:
site-packages % pip install email_validator
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: email_validator in /Users/STL34/Library/Python/3.7/lib/python/site-packages (1.1.1)
Requirement already satisfied: idna>=2.0.0 in /Users/STL34/Library/Python/3.7/lib/python/site-packages (from email_validator) (2.10)
Requirement already satisfied: dnspython>=1.15.0 in /Users/STL34/Library/Python/3.7/lib/python/site-packages (from email_validator) (1.16.0)
And doesn't install it in my project folder.
Here is the code:
from flask_wtf import FlaskForm
from wtforms import StringField, PasswordField, SubmitField, BooleanField
from wtforms.validators import DataRequired, Length, Email, EqualTo
class RegistrationForm(FlaskForm):
username = StringField('Username',
validators=[DataRequired(), Length(min=2, max=20)])
email = StringField('Email',
validators=[DataRequired(), Email()])
password = PasswordField('Password', validators=[DataRequired()])
confirm_password = PasswordField('Confirm Password',
validators=[DataRequired(), EqualTo('password')])
submit = SubmitField('Sign Up')
class LoginForm(FlaskForm):
email = StringField('Email',
validators=[DataRequired(), Email()])
password = PasswordField('Password', validators=[DataRequired()])
remember = BooleanField('Remember Me')
submit = SubmitField('Login')
I resolved the issue. I used pip with a -t flag to install email_validator in my project folder site packages folder. Without the -t flag pip installs email_validator in the Python3 site-packages folder and that doesn't work.