2

I want to run this repository https://github.com/werner-duvaud/muzero-general in jupyter notebook, but when I copied all the code and upload all the file in jupyter, I have got this error:

os.listdir(os.path.dirname(os.path.realpath(__file__)) + "/games")

Should I use the clone ...? could help me to solve this problem? Thank you

  • Does this answer your question? [\_\_file\_\_ does not exist in Jupyter Notebook](https://stackoverflow.com/questions/39125532/file-does-not-exist-in-jupyter-notebook) – Brad Solomon Feb 01 '21 at 22:30

1 Answers1

3

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:

  1. Run it in usual python environment with 'file' variable defined
  2. 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.
Rustam A.
  • 809
  • 8
  • 15