A series of photochromic polymers were prepared by forming inclusion complexes of various spiropyrans (SPs) in the cyclodextrin cavities of the β-cyclodextrin polymer (CDP). Experimental and calculation results demonstrate that the hydrophobic β-CD cavities can encapsulate the studied SPs from an aqueous solution and form 1:2 SP/β-CD inclusion complexes. The complexes undergo reversible photoinduced isomerization from a colorless closed form with absorption maxima (λexpt) at 297–359?nm to a colored open-form photomerocyanines (PMs) with absorption maxima at 547–618?nm. For the less polar closed-form SPs, the β-CD cavity behaves similarly to toluene, providing a hydrophobic environment, and thus the?λexpt?of the inclusion complexes of SPs with the β-CD in CDP is increased compared with that of ethanol solutions of the SPs. However, the structure effects from the steric hindrance of the β-CD cavity reduce the energy gap of excitation and further increase the?λexpt?of SPs. For zwitterionic open-form PMs, the hydroxyl groups, laced on the rims of β-CD, act similarly to ethanol. The interaction effects from the hydroxyl groups simultaneously lower the ground- and excited-state energy of the SPs. The competing effects between the structure and interaction factors cause changes in the?λexpt?of SPs.