简体   繁体   English

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

[英]ModuleNotFoundError: No module named 'bcrypt'

I'm having some issues trying to use flask-bcrypt.我在尝试使用flask-bcrypt 时遇到了一些问题。 Please read this entirely it is not as simple as installing the flask-bcrypt.请完整阅读本文,它不像安装flask-bcrypt 那样简单。 So my OS: Win10 IDE: PyCharm version: 2019.3 .所以我的操作系统:Win10 IDE:PyCharm 版本:2019.3。 Well I got to the point where I was incorporating my sqlite database and adding users directly to it.好吧,我到了合并我的 sqlite 数据库并直接向其中添加用户的地步。 I needed to install flask-bcrypt to hash passwords and store in the db.我需要安装 flask-bcrypt 来散列密码并存储在数据库中。 I opened up a cmd at C: and typed in pip install flask-bcrypt spit out the following error:我在 C: 打开一个 cmd 并输入pip install flask-bcrypt吐出以下错误:

Command "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 install --ignore-in stalled --no-user --prefix C:\\Users\\onyxb\\AppData\\Local\\Temp\\pip-build-env-e6sok_m_\\overlay --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pyp i.org/simple -- setuptools>=40.8.0 wheel "cffi>=1.1;命令“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 install --ignore-in 停止 --no-user --prefix C:\\Users\\onyxb\\AppData\\Local\\Temp\\pip-build-env-e6sok_m_\\overlay --no-warn-script-location -- no-binary :none: --only-binary :none: -i https://pyp i.org/simple -- setuptools>=40.8.0 wheel "cffi>=1.1; python_implementation != 'PyPy'"" failed with error code 1 in None python_implementation != 'PyPy'"" 在 None 中失败,错误代码为 1

when that didn't work I googled and found people suggested running it using admin privs.当那不起作用时,我用谷歌搜索并发现人们建议使用管理员权限运行它。 so I opened up cmd as administrator and ran the same command in the project directory.所以我以管理员身份打开 cmd 并在项目目录中运行相同的命令。 it said it worked.它说它有效。 I thought it did too, but it only seems to work partially(let me explain).我认为它也是如此,但它似乎只能部分工作(让我解释一下)。 if I open a cmd and run a password hash from the python terminal it works, but from Jet Brains it says the the following:如果我打开一个 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'

However when I go to my __init__.py I can tell it is install just by typing fla then the rest( flask-bcrypt ) pops up in the intellisense, and so does the Bcrypt after the import statement.但是,当我转到我的__init__.py我可以通过键入fla来判断它已安装,然后其余( flask-bcrypt )会在智能感知中弹出,导入语句后的Bcrypt也是如此。 I must have installed something incorrectly so I don't understand what is going on I appreciate any help.我一定是安装了不正确的东西,所以我不明白发生了什么,我感谢任何帮助。 Also I have tried easy_install flask-bcrypt that also gives me an error to install the following我也试过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

Any help would be greatly appreciated.任何帮助将不胜感激。 BTW I did install build tools Microsoft Visual Studio C++ 14.0 Jet Brains said it needs it.顺便说一句,我确实安装了构建工具Microsoft Visual Studio C++ 14.0 Jet Brains说它需要它。

您需要安装flask_bcrypt您可以使用以下命令进行安装:-

pip install flask-bcrypt

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM