Celeb Glow
updates | March 30, 2026

Unable to install python cryptography module

I have a python program with the line

from cryptography.hazmat.backends import default_backend

When run with python3, I get the error

ModuleNotFoundError: No module named 'cryptography'

I installed python-pip, then ran

pip install cryptography
pip install pycrypto

And I still get the same error. Any solution?

1

2 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 cryptography

This actually happened to me when I was using virtualenv so I got solution from here: ImportError after successful pip installation - Stack Overflow

Happy Coding!

1

To 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-dev

Then you can do:

pip install cryptography

Note:

  • Make sure you have a C compiler for example, gcc, already installed
  • Replace python3-dev with python-dev if you are working with python2

Hope this helps.

For more info: check here

Namaste 🙏

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy