首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法在python 3环境中运行bcrpyt或werkzeug。

无法在python 3环境中运行bcrpyt或werkzeug。
EN

Stack Overflow用户
提问于 2021-07-06 02:58:31
回答 2查看 104关注 0票数 0

我正在编写一门关于烧瓶和python 3的课程。我在requirement.txt文件中设置了一个python3.6环境,其中包含以下库:

代码语言:javascript
复制
alembic==0.9.9
blinker==1.4
chardet==3.0.4
click==6.7
Flask==1.0.2
Flask-Dance==0.14.0
Flask-DebugToolbar==0.10.1
Flask-Login==0.4.1
Flask-Migrate==2.1.1
Flask-OAuth==0.12
Flask-OAuthlib==0.9.4
Flask-SQLAlchemy==2.3.2
Flask-WTF==0.14.2
httplib2==0.11.3
idna==2.6
itsdangerous==0.24
Jinja2==2.10
lazy==1.3
Mako==1.0.7
MarkupSafe==1.1.1
oauth2==1.9.0.post1
oauthlib==2.0.7
python-dateutil==2.7.2
python-editor==1.0.3
requests==2.18.4
requests-oauthlib==0.8.0
six==1.11.0
SQLAlchemy==1.2.6
SQLAlchemy-Utils==0.33.2
urllib3==1.22
URLObject==2.4.3
Werkzeug==0.14.1
wincertstore==0.2
WTForms==2.1

我试图在环境中运行这个脚本:

代码语言:javascript
复制
#pip install flask-bcrypt
from flask_bcrypt import Bcrypt

# Create the Hasher
bcrypt = Bcrypt()

hashed_pass = bcrypt.generate_password_hash('mypassword')
print(hashed_pass)
wrong_check = bcrypt.check_password_hash(hashed_pass, 'wrongpass')
print(wrong_check)
right_check = bcrypt.check_password_hash(hashed_pass, 'mypassword')
print(right_check)

但我知道这个错误:

代码语言:javascript
复制
(myflaskenv2) C:\Users\dthomas\Documents\python_projects\Python and Flask Bootcamp\authentication>bcrypt-attempt.py
Traceback (most recent call last):
  File "C:\Users\dthomas\Documents\python_projects\Python and Flask Bootcamp\authentication\bcrypt-attempt.py", line 2, in <module>
    from flask_bcrypt import Bcrypt
ModuleNotFoundError: No module named 'flask_bcrypt'

同样,当我尝试一个werkzeug脚本时:

代码语言:javascript
复制
# pip install Werkzeug
from werkzeug.security import generate_password_hash,check_password_hash

# Can add options to this like salt and method
# For example: method='pbkdf2:sha256', salt_length=8 (these are defaults)
hashed_pass = generate_password_hash('mypassword')
print(hashed_pass)
wrong_check = check_password_hash(hashed_pass,'wrong')
print(wrong_check)
right_check = check_password_hash(hashed_pass,'mypassword')
print(right_check)

我知道这个错误:

代码语言:javascript
复制
Traceback (most recent call last):
  File "C:\Users\dthomas\Documents\python_projects\Python and Flask Bootcamp\authentication\werkzeug-attempt.py", line 2, in <module>
    from werkzeug.security import generate_password_hash,check_password_hash
ModuleNotFoundError: No module named 'werkzeug'

我试过:

  • 重新创造新的环境
  • 卸载,安装不同
  • pip2和pip3中的werkzeug版本,无论是在 环境
  • 在不同的电脑上试过

有人知道这个问题吗?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2021-07-06 13:48:23

哇,这太尴尬了。

我输入的是attempt-werkzeug.py而不是python attempt-werkzeug.py

抱歉给你添乱了

票数 0
EN

Stack Overflow用户

发布于 2021-07-06 05:33:07

也许您应该尝试升级Werkzeug,我的是Werkzeug==2.0.0和Flask==2.0.0。这似乎是一个版本问题。尝试:

代码语言:javascript
复制
pip install --upgrade werkzeug

而且,您的requirements.txt中似乎没有requirements.txt,您可以看到安装细节这里

代码语言:javascript
复制
pip install Flask-Bcrypt

现在再试一次。您也可能希望升级水瓶:

代码语言:javascript
复制
pip install --upgrade Flask
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/68263997

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档