我有一個Flask應用程序已經部署到Ubuntu實例以及在我的本地virtualenv中正常工作。問題在於延伸Bcrypt的Flask-Bcrypt。當我部署到AWS青苗我收到以下錯誤:Flask-Bcrypt - AttributeError:'module'對象沒有屬性'ffi' - 部署到AWS Beanstalk
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 source code我可以看到FFI
從cffi
進口:
from cffi import FFI
正如你可以從下面我PIP輸出中看到,已安裝cffi==1.9.1
。但是,如果我跑which cffi
我可以看到:
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: []
我已經看到了這個問題here這表明一個包衝突。但是,我沒有安裝py-bcrypt
。
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
任何幫助極大的讚賞。