Does Sphinx run my code on executing 'make html'?
When using autodoc, Sphinx imports the documented modules, so all module-level code is executed. This happens every time you do "make html". In that sense, Sphinx does "run" your code.
You may have to organize your code a bit differently to make the errors go away (move module-level code to functions). See this question for an example of what can happen.
This is my guess but it may not be the whole story. It's hard to say more without additional information.
def main():
print('hello world')
if __name__ == '__main__':
main()
This way your code will not be run.