pyepics
raw JSON → 3.5.9 verified Fri May 01 auth: no python
A Python interface to the Epics Channel Access protocol, providing client-side access to EPICS process variables (PVs). Current version 3.5.9, supports Python >=3.10. Released roughly every few months.
pip install pyepics Common errors
error ModuleNotFoundError: No module named 'pyepics' ↓
cause Trying to import 'pyepics' directly. The correct import is 'epics'.
fix
Use 'from epics import PV' (the distribution is 'pyepics', but the package is 'epics').
error AttributeError: module 'epics' has no attribute 'PV' ↓
cause Incomplete import. 'epics.PV' is available only after importing from epics.
fix
Run 'from epics import PV' explicitly.
error ConnectionRefusedError: No Connection: ... ↓
cause EPICS Channel Access server not running or PV name incorrect.
fix
Verify the PV name and ensure the EPICS server is reachable (e.g., with caget from the command line).
Warnings
gotcha The top-level package is 'epics', not 'pyepics'. Always import from 'epics'. ↓
fix Use 'from epics import PV' instead of 'from pyepics import PV'.
breaking Python 3.9 support dropped in version 3.5.9. Python >=3.10 required. ↓
fix Upgrade Python to 3.10 or later. Use pyepics <3.5.9 if stuck on Python 3.9.
gotcha Callbacks are invoked in a separate thread. Ensure thread safety when modifying shared state. ↓
fix Use threading locks or queue data to main thread.
deprecated The wxlib module is outdated and uses deprecated wxPython APIs. It may break in future releases. ↓
fix Avoid wxlib if possible, or prepare to migrate to alternative GUI libraries.
Imports
- PV wrong
from pyepics import PVcorrectfrom epics import PV - caget wrong
from epics.ca import cagetcorrectfrom epics import caget - caput wrong
import caputcorrectfrom epics import caput
Quickstart
from epics import PV, caget, caput
# Connect to a PV
pv = PV('my_pv_name')
print('Connected:', pv.connect())
# Get value
value = pv.get() # or caget('my_pv_name')
print('Value:', value)
# Put value
caput('my_pv_name', 42.0) # or pv.put(42.0)
# Monitor callback
def callback(pvname, value, **kw):
print(f'{pvname} = {value}')
pv.add_callback(callback)