{"id":23008,"library":"yoctopuce","title":"Yoctopuce Python API","description":"Official Python API for Yoctopuce sensors and actuators. Provides access to USB and networked Yoctopuce devices. Current version 2.1.12672, released regularly.","status":"active","version":"2.1.12672","language":"python","source_language":"en","source_url":"https://github.com/yoctopuce/yoctolib_python","tags":["yoctopuce","sensors","iot","api"],"install":[{"cmd":"pip install yoctopuce","lang":"bash","label":"PyPI install"}],"dependencies":[],"imports":[{"note":"Direct import of yoctopuce does not expose YAPI; must import from subpackage.","wrong":"import yoctopuce","symbol":"YAPI","correct":"from yoctopuce.yapi import YAPI"},{"note":"YModule is not in the top-level package.","wrong":"from yoctopuce import YModule","symbol":"YModule","correct":"from yoctopuce.ymodule import YModule"},{"note":"YSensor is not in the top-level package.","wrong":"from yoctopuce import YSensor","symbol":"YSensor","correct":"from yoctopuce.ysensor import YSensor"}],"quickstart":{"code":"from yoctopuce.yapi import YAPI\nfrom yoctopuce.ysensor import YSensor\n\n# Register a hub (adjust as needed)\nYAPI.PreregisterHub('usb')\n# Use default hub URL 'usb' for USB devices\nYAPI.RegisterHub('usb')\nsensor = YSensor.FirstSensor()\nif sensor:\n    print(f\"Sensor: {sensor.get_friendlyName()}, value: {sensor.get_currentValue()}\")\nYAPI.FreeAPI()","lang":"python","description":"Quickstart to list first Yoctopuce sensor. Preregister 'usb' for USB, or an IP address for networked hubs."},"warnings":[{"fix":"Use IPv4 address explicitly, e.g., YAPI.PreregisterHub('192.168.1.10')","message":"YAPI.PreregisterHub() may timeout with IPv6 addresses; use IPv4 or ensure DNS resolution works.","severity":"breaking","affected_versions":">=2.1.11416"},{"fix":"Always call YAPI.PreregisterHub() then YAPI.RegisterHub() for each hub.","message":"YAPI.RegisterHub() must be called after PreregisterHub() if using non-default hub.","severity":"gotcha","affected_versions":"all"},{"fix":"Always use PreregisterHub before RegisterHub.","message":"YAPI.RegisterHub() without PreregisterHub() may be removed in future versions.","severity":"deprecated","affected_versions":">=2.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"pip install yoctopuce","cause":"Package not installed or misspelled.","error":"ModuleNotFoundError: No module named 'yoctopuce'"},{"fix":"Use 'from yoctopuce.yapi import YAPI'","cause":"Importing yoctopuce directly instead of its submodules.","error":"AttributeError: module 'yoctopuce' has no attribute 'YAPI'"},{"fix":"Check hub URL, use IPv4, or ensure VirtualHub is running.","cause":"Hub URL incorrect or network issue; IPv6 address can cause timeout.","error":"YAPI.RegisterHub failed: timeout"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}