Search code examples
pythondatabasehashflask-restfulpasslib

passlib cannot be imported when using uwsgi


I'm using flask-restful and wanted to use bcrypt from passlib to hash users passwords stored in database, when I run the solution by python3 app.py, everything works perfectly and I can hash the passwords and validate them , but when I run the solution through uwsgi uwsgi uwsgi.ini I get internal server error when I try to authenticate.

When I review the log file from passlib.hash import bcrypt ImportError: No module named 'passlib' , although I can import it successfully from command line as well.

I tried to do one solution suggested in :

No module named 'passlib'

and to add "#@UnresolvedImport" to import but still didn't work.


Solution

  • After not getting any answer , I was struggling for couple of days, afterward I just deleted the virtual environment , created a new one and re-installed all required libraries "flask , flask-restful , flask_bcrypt...etc , and even uwsgi ".

    Afterward I could start the application with uwsgi without getting the ImportError.