{"id":28026,"library":"p4p","title":"p4p","description":"Python interface to PVAccess (PV Access) protocol client for EPICS. Current version 4.2.2, supports Python >=2.7. Maintained by EPICS community, follow EPICS release cadence.","status":"active","version":"4.2.2","language":"python","source_language":"en","source_url":"https://github.com/mdavidsaver/p4p","tags":["epics","pva","pvaccess","control-system","ca"],"install":[{"cmd":"pip install p4p","lang":"bash","label":"PyPI"}],"dependencies":[{"reason":"Required for numeric channel data handling.","package":"numpy","optional":false},{"reason":"Used for process monitoring and resource management.","package":"psutil","optional":true}],"imports":[{"note":"Direct import of p4p does not expose the client; must import submodule.","wrong":"import p4p","symbol":"pva","correct":"from p4p.client import pva"},{"note":"PV class is inside pva submodule.","wrong":"from p4p import PV","symbol":"PV","correct":"from p4p.client.pva import PV"},{"note":"Channel class is inside pva submodule.","wrong":"from p4p import Channel","symbol":"Channel","correct":"from p4p.client.pva import Channel"},{"note":"Context is inside client submodule.","wrong":"from p4p import Context","symbol":"Context","correct":"from p4p.client import Context"}],"quickstart":{"code":"import os\nfrom p4p.client.pva import Context\n\nwith Context('pva') as ctx:\n    value = ctx.get(os.environ.get('PV_NAME', 'blah:example'))\n    print(value)\n\n# Alternatively, using channel for monitoring:\nwith Context('pva') as ctx:\n    ch = ctx.monitor(os.environ.get('PV_NAME', 'blah:example'))\n    for update in ch:\n        print(update)\n        break  # just one sample","lang":"python","description":"Create a PVA client context, fetch a value or monitor a PV."},"warnings":[{"fix":"Use Python 3.6+ or pin to p4p==3.x.","message":"p4p 4.0 removed support for Python 2.7. Users on older systems must pin to p4p<4.0.","severity":"breaking","affected_versions":">=4.0.0"},{"fix":"Update imports to `from p4p.client import Context`.","message":"Context usage changed: old import path `from p4p import Context` no longer works; use `from p4p.client import Context`.","severity":"breaking","affected_versions":">=4.0.0"},{"fix":"Migrate from `from p4p.client import rpc` to `from p4p.client.pva import Context`.","message":"The `rpc` module (p4p.client.rpc) is deprecated in favor of new `p4p.client.pva` for all operations. Expect removal in a future major release.","severity":"deprecated","affected_versions":">=4.1.0"},{"fix":"Check site's PV Access provider setting (e.g., EPICS_PVA_PROVIDER). Use `Context('pva')` for native PVA, or `Context('ca')` for Channel Access relay.","message":"Many examples use `Context('pva', ...)` but the provider string is environment-specific. Default provider 'pva' works for most sites, but if server uses 'ca' or custom, must specify correctly.","severity":"gotcha","affected_versions":"all"},{"fix":"Use callback-based monitoring: `ch = ctx.monitor(...); ch.start(lambda x: print(x))`","message":"Monitoring channels using `ctx.monitor()` returns an iterator that blocks indefinitely. For GUI or non-blocking applications, use `ch = ctx.monitor(...); ch.start()` with callbacks (see docs for `start` method).","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-09T00:00:00.000Z","next_check":"2026-08-07T00:00:00.000Z","problems":[{"fix":"Change to: `from p4p.client import Context`","cause":"Using old import path: `from p4p import Context`. Context moved to `p4p.client` in v4.","error":"ImportError: cannot import name 'Context' from 'p4p'"},{"fix":"Use `from p4p.client.pva import Context` and use `.rpc()` method on context instead of separate rpc module.","cause":"The rpc module was deprecated and removed in p4p 4.2.","error":"ModuleNotFoundError: No module named 'p4p.client.rpc'"},{"fix":"Use `Context('pva')` instead of `Context(provider='pva')`.","cause":"In p4p <4.0, Context accepted `provider` as keyword; later versions use positional first argument.","error":"TypeError: __init__() got an unexpected keyword argument 'provider'"},{"fix":"Check PV name spelling, network connectivity, or increase timeout: `ctx.get('pvname', timeout=10)`","cause":"PV name not found or network issues; default timeout is 5 seconds.","error":"p4p.client.pva.ChannelTimeout: Channel timeout"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}