Select the armature bone.
Further to the answer by @yhoho a pose bone has a bpy.types.PoseBone.bone property pointing to its associated armature bone.
Example from python console (where C = bpy.context) , bone of interest has name "Bone", armature object has context.
When unsure of things the python console is a handy way to interactively see what's what
>>> C.object
bpy.data.objects['Armature']
>>> pb = C.object.pose.bones.get("Bone")
>>> pb
bpy.data.objects['Armature'].pose.bones["Bone"]
its associated armature bone, from its bone property
>>> pb.bone
bpy.data.armatures['Armature'].bones["Bone"]
Which tells us could also get this via the armature, ie the data part of the armature object.
>>> arm = C.object.data
>>> arm
bpy.data.armatures['Armature']
>>> bone = arm.bones.get("Bone")
>>> bone
bpy.data.armatures['Armature'].bones["Bone"]
The two bones referenced in different ways are equal
>>> bone == pb.bone
True
but are not an instance of same object,
>>> bone is pb.bone
False
A bone from the armature bones collection of type bpy.types.Bone has a select property, whereas a pose bone bpy.types.PoseBone from an armature objects pose bone collection has not (AFAIK never has).
Hence as shown to select, can use either of
pb.bone.select = True
bone.select = True
The idea of using collection.get(name) is that it returns None if the named item does not exist and can be checked against None (boolean False) and handled.
>>> pb = C.object.pose.bones.get("NonExistentBone")
>>> pb is None
True
Related
Set active bone in pose mode from Python script
myPoseBone.bone.select = Truealtering line above such that "My Pose Bone" is actually a pose bone, not an armature bone. – batFINGER Sep 23 '20 at 08:47