aimacode / aima-python

Python implementation of algorithms from Russell And Norvig's "Artificial Intelligence - A Modern Approach"
MIT License
8.07k stars 3.81k forks source link

notebook.py causes ModuleNotFoundError when using PyCharm #1294

Open SuomiKP31 opened 9 months ago

SuomiKP31 commented 9 months ago

Running logic.ipynb in JetBrains PyCharm will execute this script (Located in "<venv/Scripts/jupyter-notebook-script.py>") to start the Jupyter server. The python version is 3.10, both venv & conda were tested.

import re
import sys

from notebook.app import main

if __name__ == '__main__':
    sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
    sys.exit(main())

A ModuleNotFoundError will be raised here since there's a file named "notebook.py" within the root folder of AIMA. The script will report that "notebook" is not a module thus it cannot do "from notebook.app import main". Renaming this file to "notebook_AIMA" fixed the problem.