How can I delete a poorly named vocabulary?
Where are you calling that code? Is the $vid really right? You say it has spaces in it? Did you try to delete them from the UI?
Under /admin/structure/taxonomies where you have all vocabularies listed, open the operations dropdown and click &quot;Edit vocabulary&quot;.

On the next page click &quot;Delete&quot;.