[英]Python - Can't import bcrypt in local app engine dev server
I am trying to develop a simple forum site for my udacity assignment.我正在尝试为我的 udacity 任务开发一个简单的论坛站点。 It is not a strict requirement to use the bcrypt for password hashing, but I'd like to do it because I also like to know how to use third party libraries which are not provided by Google.
使用 bcrypt 进行密码散列并不是一个严格的要求,但我想这样做,因为我也想知道如何使用 Google 未提供的第三方库。
Following instructions provided here (installing a third-party library), I have created a folder named lib, and installed bcrypt library with following command:按照此处提供的说明(安装第三方库),我创建了一个名为 lib 的文件夹,并使用以下命令安装了 bcrypt 库:
python -m pip install -t lib/ bcrypt
I have the lib folder automatically structred like this:我有像这样自动构建的 lib 文件夹:
I also created an appengine_config.py file with following content, as per instructions in above manual:我还按照上述手册中的说明创建了一个包含以下内容的 appengine_config.py 文件:
# appengine_config.py
from google.appengine.ext import vendor
# add lib folder as vendor directory
vendor.add('lib')
At this point, I am unable to import the bcrypt to my scripts.此时,我无法将 bcrypt 导入我的脚本。 The import commands I tried so far are as follows:
到目前为止我尝试过的导入命令如下:
from lib import bcrypt
ImportError: No module named lib
导入错误:没有名为 lib 的模块
import bcrypt
ImportError: No module named bcrypt._bcrypt
导入错误:没有名为 bcrypt._bcrypt 的模块
from lib.bcrypt import bcrypt
ImportError: No module named lib.bcrypt
导入错误:没有名为 lib.bcrypt 的模块
What am I missing?我错过了什么?
As Avinash Raj pointed out, and as already pointed out in referenced manual, one cannot use python libraries with c extensions. 正如Avinash Raj指出的那样,正如已经在引用的手册中指出的那样,人们不能使用带有c扩展的python库。 So I downloaded the py-bcrypt , it worked like a charm.
所以我下载了py-bcrypt ,它就像一个魅力。
For any newbie like me who needs it, here is the steps you have to take: 对于像我这样需要它的新手,这里是你必须采取的步骤:
pybcrypt
pybcrypt
appengine_config.py
file, as outlined in here appengine_config.py
文件,如概述这里 from pybcrypt import bcrypt
from pybcrypt import bcrypt
这是另一种选择,您需要先设置Wheel 包,然后才能导入bcrypt
pip install wheel
pip install bcrypt
from flask_bcrypt import Bcrypt
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.