No module named bcrypt

Question:

Does Python version 2.7 have bcrypt in its library?

I tried import bcrypt and got the following error:

Traceback (most recent call last):
  File "register.py", line 7, in <module>
    import bcrypt
ImportError: No module named bcrypt
Asked By: Erina

||

Answers:

bcrypt is available as a pip package for python 2.7, so yes, it supports python 2.7.

It does not come by default with your python installation though, you need to pip install bcrypt in your python environment to import bcrypt successfully

Answered By: GPhilo

As jonsharpe mentioned, bcrypt is not in standard python library, but it can be easily installed and used in python 2.7

From terminal, just try

sudo pip install bcrypt

And you should be able to do

import bcrypt

without issue.

Answered By: rob

The following error for me was caused by an upgrade in the version of python.

There are two ways to fix, you can downgrade to the old version of python or you can purge that old version by running the following commands.

sudo apt-get clean

&&
sudo apt-get autoremove –purge

&&
sudo apt-get remove python

&&

sudo apt-get autoremove

Then create a virtualenv with the new python version and install your dependencies. All the best!

Answered By: MJG
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.