Flask-Bcrypt-AttributeError:“模块"对象没有属性"ffi"-部署到AWS Beanstalk [英] Flask-Bcrypt - AttributeError: 'module' object has no attribute 'ffi' - deployed to AWS Beanstalk
问题描述
我有一个Flask应用程序,该应用程序已部署到Ubuntu实例,并且可以在我的本地virtualenv中正常工作.问题出在Flask-Bcrypt,它扩展了Bcrypt.当我部署到AWS Beanstalk时,出现以下错误:
I have a Flask application which has been deployed to Ubuntu instances as well as working correctly in my local virtualenv. The issue lies with Flask-Bcrypt, which extends Bcrypt. When I deploy to AWS Beanstalk I receive the follow error:
File "/opt/python/current/app/application.py", line 391, in user_login
if bc.check_password_hash(user.password, password):
File "/opt/python/run/venv/lib/python2.7/site-packages/flask_bcrypt.py", line 193, in check_password_hash
return safe_str_cmp(bcrypt.hashpw(password, pw_hash), pw_hash)
File "/opt/python/run/venv/lib64/python2.7/site-packages/bcrypt/__init__.py", line 82, in hashpw
hashed = _bcrypt.ffi.new("char[]", 128)
AttributeError: 'module' object has no attribute 'ffi'
查看 Bcrypt源代码 FFI
是从cffi
导入的:
from cffi import FFI
从下面的我的pip输出中可以看到,已安装cffi==1.9.1
.但是,如果运行which cffi
,我可以看到:
As you can see from my pip output below, cffi==1.9.1
is installed. However, if I run which cffi
I can see:
no cffi in (/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/opt/aws/bin:/home/ec2-user/.local/bin:/home/ec2-user/bin)
系统信息:64bit Amazon Linux 2016.09 v2.3.0 running Python 2.7
这些软件包安装在eb deploy
上:
packages:
yum:
gcc-c++: []
python27-devel: []
gcc: []
libffi-devel : []
openssl-devel: []
I have seen this issue here which suggests a package conflict. However, I do not have py-bcrypt
installed.
pip freeze
返回以下内容:
aws-cfn-bootstrap==1.4
aws-elasticbeanstalk-tools==1.19
awscli==1.11.17
awscli-cwlogs==1.3.3
Babel==0.9.4
backports.ssl-match-hostname==3.4.0.2
bcrypt==3.1.2
boto==2.42.0
botocore==1.4.74
cffi==1.9.1
chardet==2.0.1
click==6.7
cloud-init==0.7.6
colorama==0.2.5
configobj==4.7.2
cryptography==1.7.1
docopt==0.4.0
docutils==0.11
ecdsa==0.11
enum34==1.1.6
Flask==0.12
Flask-Bcrypt==0.7.1
futures==3.0.3
idna==2.2
iniparse==0.3.1
ipaddress==1.0.18
itsdangerous==0.24
Jinja2==2.7.2
jmespath==0.9.0
jsonpatch==1.2
jsonpointer==1.0
kitchen==1.1.1
lockfile==0.8
mandrill==1.0.57
MarkupSafe==0.11
meld3==1.0.2
paramiko==1.15.1
PIL==1.1.6
ply==3.4
pyasn1==0.1.9
pycparser==2.17
pycurl==7.19.0
pygpgme==0.3
pyliblzma==0.5.3
pystache==0.5.3
python-daemon==1.5.2
python-dateutil==2.1
pyxattr==0.5.0
PyYAML==3.10
requests==1.2.3
rsa==3.4.1
simplejson==3.6.5
six==1.8.0
supervisor==3.1.3
urlgrabber==3.9.1
urllib3==1.8.2
virtualenv==12.0.7
Werkzeug==0.11.15
yum-metadata-parser==1.1.4
任何帮助,我们将不胜感激.
Any help greatly appreciated.
推荐答案
bcrypt
,py-bcrypt
和Flask-Bcrypt
之间似乎存在冲突.
It seems as though there is a conflict between bcrypt
, py-bcrypt
, and Flask-Bcrypt
.
我也遇到了同样的问题,所以我点了全部卸载.然后仅安装bcrypt
,因为我不需要Flask-Bcrypt
.
I had this same issue, so I pip uninstalled all of them. Then re-installed only bcrypt
since I didn't need Flask-Bcrypt
.
这解决了错误.
这篇关于Flask-Bcrypt-AttributeError:“模块"对象没有属性"ffi"-部署到AWS Beanstalk的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!