How to Install qrcode in Python
QR Code image generator
pip install qrcode
Quick Fix
ModuleNotFoundError: No module named 'qrcode'
pip install "qrcode[pil]"
pip install qrcode (correct usage)
pip install "qrcode[pil]"
pip install qrcode 7.4.2
pip install "qrcode[pil]==7.4.2"
What is qrcode?
QR Code image generator
A standard install uses pypng to generate PNG files and can also render QR codes directly to the console. A standard install is just::
For more image functionality, install qrcode with the `` dependency so that pillow is installed and can be used for generating images::
A Quick Response code is a two-dimensional pictographic code used for its fast readability and comparatively large storage capacity. The code consists of black modules arranged in a square pattern on a white background. The information encoded can be made up of any kind of data (e.g., binary, alphanumeric, or Kanji symbols)
Quick Start
Minimal example to get started with qrcode:
import qrcode
print(qrcode.__version__)
Installation
pip (standard)
pip install qrcode
Virtual environment (recommended)
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
pip install qrcode
pip3
pip3 install qrcode
conda
conda install -c conda-forge qrcode
Poetry
poetry add qrcode
Dependencies
Installing qrcode will also install these packages:
Verify the Installation
After installing, confirm the package is available:
python -c "import qrcode; print(qrcode.__version__)"
If this prints a version number, installation succeeded. If you see a ModuleNotFoundError, see the errors section below.
ModuleNotFoundError: No module named 'qrcode'
ModuleNotFoundError: No module named 'qrcode'
Fix:
pip install "qrcode[pil]"
Variants:
pip3 install "qrcode[pil]"
python -m pip install "qrcode[pil]"
source venv/bin/activate && pip install "qrcode[pil]"
Diagnose:
pip show qrcode
which python && which pip
The package is not installed in the current Python environment. The [pil] extra installs Pillow, required for image output.
import qrcode ModuleNotFoundError: No module named 'qrcode'
import qrcode
ModuleNotFoundError: No module named 'qrcode'
Fix:
python -m pip install "qrcode[pil]"
Variants:
pip3 install "qrcode[pil]"
source venv/bin/activate && pip install "qrcode[pil]"
Diagnose:
python -c "import sys; print(sys.executable)"
pip show qrcode
Using python -m pip guarantees the package installs into the same interpreter that runs your script.
qrcode installed but ModuleNotFoundError still appears
Symptom: pip install qrcode succeeds, then import qrcode still raises ModuleNotFoundError.
Fix:
python -m pip install "qrcode[pil]"
Variants:
pip3 install "qrcode[pil]"
source venv/bin/activate && pip install "qrcode[pil]"
Diagnose:
pip show qrcode
python -c "import sys; print(sys.path)"
pip and python point to different environments — the install succeeded in a location the running interpreter never checks.
Still getting the error after running the fixes above? Find out exactly why pip and Python are pointing to different environments →
pip install qrcode pillow — why Pillow is required
qrcode.exceptions.ModuleNotFoundError: No module named 'PIL'
Fix:
pip install "qrcode[pil]"
Variants:
pip install qrcode pillow
pip3 install "qrcode[pil]"
python -m pip install "qrcode[pil]"
Diagnose:
python -c "import PIL; print(PIL.__version__)"
qrcode requires Pillow for PNG and image-format output. Plain pip install qrcode omits it — use qrcode[pil] to install both.
pip install qrcode 7.4.2 — install exact version
Fix:
pip install "qrcode[pil]==7.4.2"
Variants:
pip install "qrcode==7.4.2"
pip3 install "qrcode[pil]==7.4.2"
pip install --upgrade "qrcode[pil]"
Diagnose:
pip show qrcode
Version 7.4.2 was released 2023-02-05. The current latest is 8.2 (2025-05-01). Pin only if your project requires a locked dependency.
Recent Releases
| Version | Released |
|---|---|
8.2 latest |
2025-05-01 |
8.1 |
2025-04-02 |
8.0 |
2024-10-01 |
7.4.2 |
2023-02-05 |
7.4.1 |
2023-02-03 |
Manage qrcode
Upgrade to latest version
pip install --upgrade qrcode
Install a specific version
pip install qrcode==8.2
Uninstall
pip uninstall qrcode
Check what is installed
pip show qrcode