pymgclient
raw JSON → 1.5.2 verified Mon Apr 27 auth: no python
Memgraph database adapter for Python language. Current version 1.5.2, supports Python >=3.9, Linux arm64 and wider libc compatibility. Released irregularly.
pip install pymgclient Common errors
error ModuleNotFoundError: No module named 'pymgclient' ↓
cause The package name is 'pymgclient', but the Python module is 'mgclient'. The import should be 'import mgclient'.
fix
Use 'import mgclient' or 'from mgclient import connect'.
error ImportError: cannot import name 'connect' from 'mgclient' ↓
cause Using an outdated import path or the library is not installed correctly.
fix
Run 'pip install pymgclient' and import as 'from mgclient import connect'.
error AttributeError: module 'mgclient' has no attribute 'connect' ↓
cause The package may not be installed or the module name is wrong. Verify installation with 'pip list | grep pymgclient'.
fix
Reinstall with 'pip install --upgrade pymgclient' and import as described.
Warnings
breaking Python versions <3.9 are no longer supported since v1.5.0. ↓
fix Upgrade Python to >=3.9 or use an older pymgclient version.
breaking Binary wheels are no longer provided for Python <3.10 and macOS <3.9 since v1.4.0. ↓
fix Use Python >=3.10 (Linux/Windows) or >=3.9 (macOS), or build from source.
gotcha The library's top-level Python module is 'mgclient', not 'pymgclient'. Importing from 'pymgclient' directly will raise ModuleNotFoundError. ↓
fix Use 'from mgclient import ...' or 'import mgclient'.
Imports
- connect wrong
from pymgclient import connectcorrectfrom mgclient import connect
Quickstart
import os
from mgclient import connect
conn = connect(
host=os.environ.get('MG_HOST', '127.0.0.1'),
port=int(os.environ.get('MG_PORT', 7687)),
username=os.environ.get('MG_USER', ''),
password=os.environ.get('MG_PASS', '')
)
cursor = conn.cursor()
cursor.execute("MATCH (n) RETURN n LIMIT 1")
print(cursor.fetchone())
conn.close()