简体   繁体   English

Python - 无法在本地应用引擎开发服务器中导入 bcrypt

[英]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 文件夹:

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: 对于像我这样需要它的新手,这里是你必须采取的步骤:

  1. Inside your project folder, create a folder called "lib" 在项目文件夹中,创建一个名为“lib”的文件夹
  2. Extract the zip downloaded from github above, to the folder 'lib'. 将从上面的github下载的zip解压缩到文件夹'lib'。 Do not use - in your folder name. 不要在文件夹名称中使用- Name it something like pybcrypt 将它命名为pybcrypt
  3. Create the appengine_config.py file, as outlined in here 创建appengine_config.py文件,如概述这里
  4. Import the library to your script, like so: from pybcrypt import bcrypt 将库导入到您的脚本中,如下所示: from pybcrypt import bcrypt
  5. Pat yourself on the back. 拍拍自己的背部。

这是另一种选择,您需要先设置Wheel 包,然后才能导入bcrypt

pip install wheel
pip install bcrypt

from flask_bcrypt import Bcrypt

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

相关问题 ubuntu上python的Python应用程序引擎导入本地数据存储 - app engine for python on ubuntu import datastore local 无法在 Google App Engine 中导入 ctypes python 库 - Can't import the ctypes python library in Google App Engine 本地开发服务器的Google App Engine没有终端输出? - No terminal output for google app engine for local dev server? 无法在Google App Engine中导入数据存储 - Can't import datastore in Google App Engine 运行google app sdk dev_appserver.py找不到本地python环境 - Running google app sdk dev_appserver.py can't find the local python environment 用于本地开发服务器重定向到登录页面的Google App Engine远程api - google app engine remote api for local dev server redirecting to login page Python子模块导入错误(Google App Engine dev_appserver.py) - Python submodule import error (Google App Engine dev_appserver.py) Google App Engine本地开发服务器SSL警告(Python 2.7) - Google App Engine local development server SSL warning (Python 2.7) 如何将 Python 3 与 Google App Engine 的本地开发服务器一起使用 - How to use Python 3 with Google App Engine's Local Development Server 在Google App Engine开发服务器上访问BigQuery - Accessing BigQuery on Google App Engine dev server
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM