The error says:
IOError: [Errno 13] Permission denied: "C:\\Program Files (x86)\\2K Games\\Firaxis Games\\Sid Meier's Civilization 4 Complete\\Beyond the Sword\\Mods\\Caveman2Cosmos\\UserSettings\\BUG Main Interface.ini"
This is the python code line that is failing:
file = open("C:\\Program Files (x86)\\2K Games\\Firaxis Games\\Sid Meier's Civilization 4 Complete\\Beyond the Sword\\Mods\\Caveman2Cosmos\\UserSettings\\BUG Main Interface.ini", "w") ### w stands for write permission requested.
You may want to check if the game folder is set to "read only", also look at the permissions found in the security tab for the folder properties.
I'll back up a bit... right click the Caveman2Cosmos folder and select "properties" in the context menu, it should be close to, or at, the bottom of the list.
On the first page of the new window there should be a read only check box, make sure it is un-ticked. Then look at the security tab at the permission stuff.
Do apply changes to all sub-folders and files if it asks for it when you apply the changes.
Last thing... right click your Beyond the sword exe file and check its properties too, tick the run as administrator checkbox.
I believe the error lies in one of these technicalities.
If all else fails, try installing beyond the sword closer to the root of the hard-drive., the file path address may be too long...
"C:\\Program Files (x86)\\2K Games\\Firaxis Games\\Sid Meier's Civilization 4 Complete\\Beyond the Sword\\Mods\\Caveman2Cosmos\\UserSettings\\BUG Main Interface.ini"