[Solved] ModuleNotFoundError: No module named ‘cryptography’

This error means you don’t have cryptography installed. Install it with pip install cryptography or by using the user interface in your IDE to install additional python packages.

The cryptography package in Python has cryptographic “recipes” which make working with encryption easier and safer for developers. Easier because most of the hard work has already been done for you, and safer because you don’t have the opportunity to incorrectly implement a cryptographic primitive and damage the security of your entire application!

Problem: you do not have the cryptography package installed

THe following code will throw the error if you don’t have the package installed:

import cryptography

And the error:

Traceback (most recent call last):
  File "/home/user/main.py", line 1, in <module>
    import cryptography
ModuleNotFoundError: No module named 'cryptography'

Solution 1: install cryptography with pip

This is easily fixed by installing the package. Simply run the following command in your terminal to install cryptography:

pip install cryptography

Solution 2: install cryptography with PyCharm

If you’re using the popular PyCharm IDE, you can install cryptography through the user interface. First, click the “Python Packages” menu item in the bottom left hand corner:

Then, type “cryptography” in the search bar and click “Install Package”:


If you’re getting the error “ModuleNotFoundError: No module named ‘cryptography'” it just means you don’t have cryptography installed. You can install it with pip or by using the user interface of whichever IDE you’re developing with.