MurmurHash
raw JSON → 1.0.15 verified Tue May 12 auth: no python install: verified
MurmurHash is a fast, non-cryptographic hash function library, primarily used for tasks like hash table indexing, data deduplication, and probabilistic data structures. This Python library provides efficient Cython bindings for MurmurHash, offering various 32-bit and 128-bit hash variants. It is actively maintained with frequent updates to support new Python versions and architectures.
pip install murmurhash Common errors
error ERROR: Command errored out with exit status 1: ... Running setup.py install for murmurhash: finished with status 'error' ↓
cause This error typically occurs during installation when the Cython extensions for `murmurhash` cannot be compiled, often due to missing build tools (like `gcc` on Linux or C++ build tools on Windows) or an incompatible environment (e.g., specific Linux distributions like Alpine).
fix
Ensure you have the necessary C/C++ compilers installed on your system. On Debian/Ubuntu:
sudo apt-get update && sudo apt-get install build-essential python3-dev. On Windows, install 'Desktop development with C++' from Visual Studio Installer. For Alpine Linux, install python3-dev and gcc: apk add python3-dev gcc. error ImportError: cannot import name 'hash_unicode' from 'murmurhash' ↓
cause This error indicates that the `hash_unicode` function, or similar specific hashing functions, are not directly available or have been renamed in the version of `murmurhash` you have installed, often due to an outdated or conflicting installation, especially when `murmurhash` is a dependency of another library like spaCy.
fix
Upgrade
murmurhash to its latest version: pip install --upgrade murmurhash. If issues persist, consider reinstalling in a fresh virtual environment: python -m venv .venv && source .venv/bin/activate && pip install murmurhash. error AttributeError: module 'murmurhash' has no attribute 'hash' ↓
cause This error occurs when you try to call a method named `hash` directly on the `murmurhash` module, but such a top-level function does not exist, or its name has changed in the installed version.
fix
The
murmurhash library provides specific hashing functions like murmurhash.murmur3_32(), murmurhash.murmur3_128(), etc. Refer to the library's documentation or use dir(murmurhash) to find the correct function names. For example, use murmurhash.murmur3_32('your string'.encode('utf-8')). error TypeError: a bytes-like object is required, not 'int' ↓
cause The `murmurhash` functions expect binary data (bytes) as input, but you are providing an integer or a string that has not been explicitly encoded into bytes.
fix
Encode your input string to bytes before passing it to the hash function. For integers, convert them to their byte representation. Example:
murmurhash.murmur3_32('your string'.encode('utf-8')) or murmurhash.murmur3_32(b'your bytes'). Warnings
breaking Be aware that `murmurhash` (from `explosion`) is a distinct package from the widely used `mmh3` library for MurmurHash3. They have different import paths (`import murmurhash.mrmr` vs `import mmh3`) and potentially different API behaviors. Installing one and attempting to use the other's API will lead to `ImportError` or unexpected hash results. ↓
fix Ensure you `pip install murmurhash` and `import murmurhash.mrmr` for this library, or `pip install mmh3` and `import mmh3` if you intend to use the `mmh3` library. Always refer to the specific library's documentation for correct API usage.
gotcha Starting from version 1.0.7, MurmurHash2 and MurmurHash3 implementations within this library were made endian-neutral. While this ensures consistent hash values across diverse system architectures (e.g., big-endian vs. little-endian), it may produce different hash outputs compared to older `murmurhash` versions or other MurmurHash implementations that are endian-sensitive. ↓
fix If comparing hash values with systems using older versions or different MurmurHash implementations, verify their endian-neutrality. For strict compatibility with older, endian-sensitive MurmurHash outputs, manual endian handling might be necessary, or consider pinning to an older `murmurhash` version if acceptable.
gotcha MurmurHash is a non-cryptographic hash function optimized for speed and good distribution, not for security. It should not be used for cryptographic purposes such as password hashing, digital signatures, or data integrity where collision resistance and unpredictability are critical. Always use a consistent `seed` value to ensure reproducible hash outputs, especially when relying on hashes for data partitioning, caching, or lookups across different systems or application runs. ↓
fix For security-sensitive applications, use cryptographic hash functions from Python's `hashlib` module (e.g., `hashlib.sha256`). For consistent non-cryptographic hashing, explicitly pass the `seed` argument to `murmurhash.mrmr.hash()` (or `murmurhash.mrmr.hash_bytes()` for byte strings). Note that `murmurhash.mrmr` primarily provides 32-bit MurmurHash3. If 64-bit or 128-bit MurmurHash implementations are required, consider using alternative libraries such as `mmh3` or `pyfarmhash` which explicitly offer these functionalities, or ensure all parts of your system use the same default seed.
Install compatibility verified last tested: 2026-05-12
python os / libc status wheel install import disk
3.10 alpine (musl) wheel - 0.00s 18.1M
3.10 alpine (musl) - - 0.00s 18.1M
3.10 slim (glibc) wheel 1.5s 0.01s 19M
3.10 slim (glibc) - - 0.00s 19M
3.11 alpine (musl) wheel - 0.00s 20.0M
3.11 alpine (musl) - - 0.00s 20.0M
3.11 slim (glibc) wheel 1.7s 0.00s 21M
3.11 slim (glibc) - - 0.00s 21M
3.12 alpine (musl) wheel - 0.00s 11.9M
3.12 alpine (musl) - - 0.00s 11.9M
3.12 slim (glibc) wheel 1.4s 0.00s 12M
3.12 slim (glibc) - - 0.00s 12M
3.13 alpine (musl) wheel - 0.00s 11.6M
3.13 alpine (musl) - - 0.00s 11.5M
3.13 slim (glibc) wheel 1.5s 0.00s 12M
3.13 slim (glibc) - - 0.00s 12M
3.9 alpine (musl) wheel - 0.00s 17.6M
3.9 alpine (musl) - - 0.00s 17.6M
3.9 slim (glibc) wheel 1.8s 0.01s 18M
3.9 slim (glibc) - - 0.00s 18M
Imports
- hash wrong
import mmh3correctimport murmurhash.mrmr murmurhash.mrmr.hash('data') - hash64
import murmurhash.mrmr murmurhash.mrmr.hash64('data') - hash128
import murmurhash.mrmr murmurhash.mrmr.hash128('data')
Quickstart last tested: 2026-04-24
import murmurhash.mrmr
# Hash a string (UTF-8 encoded by default)
text_hash = murmurhash.mrmr.hash('hello world', seed=42)
print(f"32-bit hash for 'hello world': {text_hash}")
# Hash bytes
bytes_hash = murmurhash.mrmr.hash(b'hello world', seed=42)
print(f"32-bit hash for b'hello world': {bytes_hash}")
# Get a 64-bit hash
hash_64 = murmurhash.mrmr.hash64('another example', seed=0)
print(f"64-bit hash: {hash_64}")
# Get a 128-bit hash (returns a tuple of two integers)
hash_128 = murmurhash.mrmr.hash128('long string data', seed=12345)
print(f"128-bit hash: {hash_128}")
# Example with environment variable for seed (not typical for hash, but for auth template)
# import os
# seed_from_env = int(os.environ.get('MURMURHASH_SEED', '0'))
# env_hash = murmurhash.mrmr.hash('secure_data', seed=seed_from_env)
# print(f"Hash with env seed: {env_hash}")