Unable to install python cryptography module
I have a python program with the line
from cryptography.hazmat.backends import default_backendWhen run with python3, I get the error
ModuleNotFoundError: No module named 'cryptography'I installed python-pip, then ran
pip install cryptography
pip install pycryptoAnd I still get the same error. Any solution?
12 Answers
I think there are multiple versions of python interpreters and pip versions present. So in order to install the cryptography package try using this
python -m pip install cryptographyThis actually happened to me when I was using virtualenv so I got solution from here: ImportError after successful pip installation - Stack Overflow
Happy Coding!
1To install cryptography you need the following packages to be installed first:-build-essentials, python-dev, libssl-dev, libffi-dev
Simply run:
sudo apt-get install build-essentials python3-dev libssl-dev libffi-devThen you can do:
pip install cryptographyNote:
- Make sure you have a
Ccompiler for example,gcc, already installed- Replace
python3-devwithpython-devif you are working withpython2
Hope this helps.
For more info: check here
Namaste 🙏