How to Install cryptography in Python
cryptography is a package which provides cryptographic recipes and primitives to Python developers.
pip install cryptography
What is cryptography?
cryptography is a package which provides cryptographic recipes and primitives to Python developers.
`` is a package which provides cryptographic recipes and primitives to Python developers. Our goal is for it to be your "cryptographic standard library". It supports Python 3.8+ and PyPy3 7.3.11+.
`` includes both high level recipes and low level interfaces to common cryptographic algorithms such as symmetric ciphers, message digests, and key derivation functions. For example, to encrypt something with ``'s high level symmetric encryption recipe:
>>> from cryptography.fernet import Fernet >>> # Put this somewhere safe! >>> key = Fernet.generatekey() >>> f = Fernet(key) >>> token = f.encrypt(b"A really secret message. Not for prying eyes.") >>> token b'...' >>> f.decrypt(token) b'A really secret message. Not for prying eyes.'
Quick Start
Minimal example to get started with cryptography:
import cryptography
print(cryptography.__version__)
Installation
pip (standard)
pip install cryptography
Virtual environment (recommended)
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
pip install cryptography
pip3
pip3 install cryptography
conda
conda install -c conda-forge cryptography
Poetry
poetry add cryptography
Dependencies
Installing cryptography will also install these packages:
Verify the Installation
After installing, confirm the package is available:
python -c "import cryptography; print(cryptography.__version__)"
If this prints a version number, installation succeeded. If you see a ModuleNotFoundError, see the errors section below.
Installation Errors
Common errors when installing cryptography with pip.
ModuleNotFoundError: No module named 'cryptography'
Cause: The package is not installed in the current Python environment.
Fix: Run pip install cryptography. If using a virtual environment, ensure it is activated first.
ModuleNotFoundError: No module named 'cryptography' (installed but still failing)
Cause: pip installed the package into a different Python than the one running your script.
Fix: Use python -m pip install cryptography to install into the interpreter you are running.
ImportError: cannot import name 'X' from 'cryptography'
Cause: The function or class does not exist in the installed version.
Fix: Check the version with pip show cryptography and upgrade with pip install --upgrade cryptography.
pip: command not found
Cause: pip is not in PATH or Python was not added to PATH during installation.
Fix: Try python -m pip install cryptography. On macOS/Linux try pip3.
PermissionError: [Errno 13] Permission denied
Cause: No write access to the system Python package directory.
Fix: Use a virtual environment, or add --user: pip install --user cryptography
SSL: CERTIFICATE_VERIFY_FAILED
Cause: pip cannot verify PyPI's SSL certificate — common behind corporate proxies.
Fix: Try: pip install --trusted-host pypi.org --trusted-host files.pythonhosted.org cryptography
Recent Releases
| Version | Released |
|---|---|
46.0.7 latest |
2026-04-08 |
46.0.6 |
2026-03-25 |
46.0.5 |
2026-02-10 |
46.0.4 |
2026-01-28 |
46.0.3 |
2025-10-15 |
Manage cryptography
Upgrade to latest version
pip install --upgrade cryptography
Install a specific version
pip install cryptography==46.0.7
Uninstall
pip uninstall cryptography
Check what is installed
pip show cryptography