ntg
ntg

Reputation: 14075

How to check if the code is running in voila or jupyter

It is strange that I cannot seem to find this question already here, but I did multiple searches... Maybe Google and so find are messing with me... Anyway, need a question people (including my future self) will be able to find with a Google search, so:

How can I check if the code is executing in voila vs. e.g. in jupyter?

Upvotes: 1

Views: 138

Answers (1)

ntg
ntg

Reputation: 14075

Turns out this is easy on newer versions of jupyter/voila....

import os
running_in_voila = os.environ.get('SERVER_SOFTWARE','jupyter').startswith('voila')

Upvotes: 1

Related Questions