I am doing a course in flask and python 3. I have set up a python 3.6 environment with the following libraries in a requirement.txt file:
JavaScript
x
35
35
1
alembic==0.9.9
2
blinker==1.4
3
chardet==3.0.4
4
click==6.7
5
Flask==1.0.2
6
Flask-Dance==0.14.0
7
Flask-DebugToolbar==0.10.1
8
Flask-Login==0.4.1
9
Flask-Migrate==2.1.1
10
Flask-OAuth==0.12
11
Flask-OAuthlib==0.9.4
12
Flask-SQLAlchemy==2.3.2
13
Flask-WTF==0.14.2
14
httplib2==0.11.3
15
idna==2.6
16
itsdangerous==0.24
17
Jinja2==2.10
18
lazy==1.3
19
Mako==1.0.7
20
MarkupSafe==1.1.1
21
oauth2==1.9.0.post1
22
oauthlib==2.0.7
23
python-dateutil==2.7.2
24
python-editor==1.0.3
25
requests==2.18.4
26
requests-oauthlib==0.8.0
27
six==1.11.0
28
SQLAlchemy==1.2.6
29
SQLAlchemy-Utils==0.33.2
30
urllib3==1.22
31
URLObject==2.4.3
32
Werkzeug==0.14.1
33
wincertstore==0.2
34
WTForms==2.1
35
And I am trying to run this scripts in the environment:
JavaScript
1
13
13
1
#pip install flask-bcrypt
2
from flask_bcrypt import Bcrypt
3
4
# Create the Hasher
5
bcrypt = Bcrypt()
6
7
hashed_pass = bcrypt.generate_password_hash('mypassword')
8
print(hashed_pass)
9
wrong_check = bcrypt.check_password_hash(hashed_pass, 'wrongpass')
10
print(wrong_check)
11
right_check = bcrypt.check_password_hash(hashed_pass, 'mypassword')
12
print(right_check)
13
but I get this error:
JavaScript
1
6
1
(myflaskenv2) C:UsersdthomasDocumentspython_projectsPython and Flask Bootcampauthentication>bcrypt-attempt.py
2
Traceback (most recent call last):
3
File "C:UsersdthomasDocumentspython_projectsPython and Flask Bootcampauthenticationbcrypt-attempt.py", line 2, in <module>
4
from flask_bcrypt import Bcrypt
5
ModuleNotFoundError: No module named 'flask_bcrypt'
6
Likewise when I try a werkzeug script:
JavaScript
1
12
12
1
# pip install Werkzeug
2
from werkzeug.security import generate_password_hash,check_password_hash
3
4
# Can add options to this like salt and method
5
# For example: method='pbkdf2:sha256', salt_length=8 (these are defaults)
6
hashed_pass = generate_password_hash('mypassword')
7
print(hashed_pass)
8
wrong_check = check_password_hash(hashed_pass,'wrong')
9
print(wrong_check)
10
right_check = check_password_hash(hashed_pass,'mypassword')
11
print(right_check)
12
I get this error:
JavaScript
1
5
1
Traceback (most recent call last):
2
File "C:UsersdthomasDocumentspython_projectsPython and Flask Bootcampauthenticationwerkzeug-attempt.py", line 2, in <module>
3
from werkzeug.security import generate_password_hash,check_password_hash
4
ModuleNotFoundError: No module named 'werkzeug'
5
I have tried:
- recreating a new environment
- uninstalling, installing different
- versions of werkzeug in pip2 and pip3, both inside and outside the
environment - tried it on different computers
Does anyone have an idea of the issue?
Advertisement
Answer
Wow, this is embarrassing.
I was typing attempt-werkzeug.py
instead of python attempt-werkzeug.py
Sorry for the confusion