How to Install redis in Python
Python client for Redis database and key-value store
pip install redis
What is redis?
Python client for Redis database and key-value store
The Python interface to the Redis key-value store.
Installation | Usage | Advanced Topics | Contributing
Note: redis-py 5.0 is the last version of redis-py that supports Python 3.7, as it has reached end of life. redis-py 5.1 supports Python 3.8+. Note: redis-py 6.1.0 is the last version of redis-py that supports Python 3.8, as it has reached end of life. redis-py 6.2.0 supports Python 3.9+.
Quick Start
Minimal example to get started with redis:
import redis
r = redis.Redis(host="localhost", port=6379, db=0)
r.set("key", "value")
print(r.get("key")) # b'value'
r.incr("counter")
print(r.get("counter")) # b'1'
Installation
pip (standard)
pip install redis
Virtual environment (recommended)
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
pip install redis
pip3
pip3 install redis
conda
conda install -c conda-forge redis
Poetry
poetry add redis
Dependencies
Installing redis will also install these packages:
Verify the Installation
After installing, confirm the package is available:
python -c "import redis; print(redis.__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 redis with pip.
ModuleNotFoundError: No module named 'redis'
Cause: The package is not installed in the current Python environment.
Fix: Run pip install redis. If using a virtual environment, ensure it is activated first.
ModuleNotFoundError: No module named 'redis' (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 redis to install into the interpreter you are running.
ImportError: cannot import name 'X' from 'redis'
Cause: The function or class does not exist in the installed version.
Fix: Check the version with pip show redis and upgrade with pip install --upgrade redis.
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 redis. 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 redis
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 redis
Runtime Errors
Common errors when using redis after installation.
redis.exceptions.ConnectionError: Error connecting to localhost:6379
Cause: Redis server is not running or not reachable.
Fix: Start Redis: redis-server or docker run -p 6379:6379 redis
redis.exceptions.ResponseError: WRONGTYPE Operation against a key
Cause: The command is incompatible with the data type stored at that key.
Fix: Use the correct command for the stored type, or delete the key with r.delete('key').
Recent Releases
| Version | Released |
|---|---|
8.0.0b1 |
2026-04-08 |
7.4.0 latest |
2026-03-24 |
7.3.0 |
2026-03-06 |
7.2.1 |
2026-02-25 |
7.2.0 |
2026-02-16 |
Manage redis
Upgrade to latest version
pip install --upgrade redis
Install a specific version
pip install redis==7.4.0
Uninstall
pip uninstall redis
Check what is installed
pip show redis