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!
Table of Contents
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
PythonAnd 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
ShellScriptSolution 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”:
Conclusion
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.
John is a professional software engineer who has been solving problems with code for 15+ years. He has experience with full stack web development, container orchestration, mobile development, DevOps, Windows and Linux kernel development, cybersecurity, and reverse engineering. In his spare time, he’s researching the potential business applications of AI.