The problem arise because of environment you are using. When you run python code in Jupyter notebook you are not running usual python environment - you are running it with iPython - interactive shell (version 7.12.0 is last currently). And it doesn't define hidden variable __file__
as mainstream python environment does - so it doesn't understand where to look for '/games' folder.
What you could do:
- Run it in usual python environment with 'file' variable defined
- Try placing your Jupyter notebook file in this project folder and using os.getcwd() instead of
os.path.dirname(os.path.realpath(__file__))
or change path any other way that suits you.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…