ModuleNotFoundError:没有名为“bcrypt”的模块

2024-06-16 08:49:08 发布

您现在位置:Python中文网/ 问答频道 /正文

我在尝试使用flask bcrypt时遇到一些问题。请通读这篇文章,它不像安装烧瓶bcrypt那么简单。所以我的OS:Win10 IDE:PyCharm版本:2019.3。我已经到了合并sqlite数据库并直接向其中添加用户的地步。我需要安装flask bcrypt来散列密码并存储在数据库中。我在C:打开了一个cmd,并输入了pip install flask-bcrypt并指出了以下错误:

命令“C:\Users\onyxb\PycharmProjects\DIRT\venv\Scripts\python.exe C:\Users\onyxb\PycharmProjects\DIRT\venv\lib\site packages\pip-19.0.3-py3.8.egg\pip安装--在中忽略 暂停--无用户--前缀C:\Users\onyxb\AppData\Local\Temp\pip-build-env-e6sok\u m\ux\overlay--无警告脚本位置--无二进制:无:-仅二进制:无:-ihttps://pyp i、 组织/简单——设置工具>;=40.8.0车轮“cffi>=1.1; python_实现!='PyPy“”失败,错误代码为1,无

当这不起作用时,我在谷歌上搜索,发现有人建议使用管理员权限运行它。因此,我以管理员身份打开cmd,并在项目目录中运行相同的命令。它说它奏效了。我认为它也是,但它似乎只起了部分作用(让我解释一下)。如果我打开一个cmd并从python终端运行一个密码散列,它会工作,但是从Jet Brains它会显示以下内容:

(venv) C:\Users\onyxb\PycharmProjects\DIRT>python run.py
bcrypt is required to use Flask-Bcrypt
Traceback (most recent call last):
  File "run.py", line 1, in <module>
    from DIRT import app
  File "C:\Users\onyxb\PycharmProjects\DIRT\DIRT\__init__.py", line 3, in <module>
    from flask_bcrypt import Bcrypt
  File "C:\Users\onyxb\PycharmProjects\DIRT\venv\lib\site-packages\flask_bcrypt-0.7.1-py3.8.egg\flask_bcrypt.py", line 27, in <module>
    raise e
  File "C:\Users\onyxb\PycharmProjects\DIRT\venv\lib\site-packages\flask_bcrypt-0.7.1-py3.8.egg\flask_bcrypt.py", line 24, in <module>
    import bcrypt
ModuleNotFoundError: No module named 'bcrypt'

然而,当我转到我的__init__.py时,我可以通过键入fla来判断它是安装的,然后剩下的(flask-bcrypt)在intellisense中弹出,import语句之后的Bcrypt也会弹出。我一定是安装了不正确的东西,所以我不明白发生了什么,我感谢任何帮助。此外,我还尝试了easy_install flask-bcrypt,这也给了我一个安装以下内容的错误

(venv) C:\Users\onyxb\PycharmProjects\DIRT>easy_install flask-bcrypt
Searching for flask-bcrypt
Best match: flask-bcrypt 0.7.1
Processing flask_bcrypt-0.7.1-py3.8.egg
flask-bcrypt 0.7.1 is already the active version in easy-install.pth

Using c:\users\onyxb\pycharmprojects\dirt\venv\lib\site-packages\flask_bcrypt-0.7.1-py3.8.egg
Processing dependencies for flask-bcrypt
Searching for bcrypt
Reading https://pypi.org/simple/bcrypt/
Downloading https://files.pythonhosted.org/packages/fa/aa/025a3ab62469b5167bc397837c9ffc486c42a97ef12ceaa6699d8f5a5416/bcrypt-3.1.7.tar.gz#sha256=0b0069c752ec14172c5f78208f
1863d7ad6755a6fae6fe76ec2c80d13be41e42
Best match: bcrypt 3.1.7
Processing bcrypt-3.1.7.tar.gz
Writing C:\Users\onyxb\AppData\Local\Temp\easy_install-ggxvm9mc\bcrypt-3.1.7\setup.cfg
Running bcrypt-3.1.7\setup.py -q bdist_egg --dist-dir C:\Users\onyxb\AppData\Local\Temp\easy_install-ggxvm9mc\bcrypt-3.1.7\egg-dist-tmp-1tk8qkf0
_configtest.c
_cffi_backend.c
c:\users\onyxb\appdata\local\programs\python\python38\include\pyconfig.h(206): fatal error C1083: Cannot open include file: 'basetsd.h': No such file or directory
error: Setup script exited with error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\x86_amd64\\cl.exe' failed with exit status 2

任何帮助都将不胜感激。顺便说一下,我确实安装了构建工具<强>微软VisualStudioC++ 14 强> JaveRead 说需要它。p>


Tags: installpipinpyflaskvenveggpackages