ese-msc / introduction-to-python

"Introduction to Python" course for future Imperial College London MSc students
BSD 3-Clause "New" or "Revised" License
75 stars 94 forks source link

ModuleNotFoundError: No module named 'lecture' #53

Closed edsml-sb3323 closed 1 year ago

edsml-sb3323 commented 1 year ago

Hi, I have just set up Jupyter on my local and while running the following piece of import statements, I am getting an error: ModuleNotFoundError: No module named 'lecture'. There is no error while running -> import pybryt.

Surprisingly, If I run the same import statement(from lecture import pybryt_reference) on the online Jupyter link mentioned in the readme of Github, I am getting the same error. Any suggestions to resolve it would be helpful. Thanks!

image

marijanbeg commented 1 year ago

HI @edsml-10f37f99, thank you for raising this issue. Have you maybe moved the notebook (.ipynb) file or lecture.py? Please note that lecture.py must be in the same directory as the notebook you are running.

edsml-sb3323 commented 1 year ago

I rechecked that I haven't moved any files. I directly opened the Jupyter link in my browser as well and an error came up just after importing the statement. I tried recloning the repo as well on my local machine and found the same error.

When I checked inside my bin folder, I didn't find the lecture module either.

image

marijanbeg commented 1 year ago

Thank you for the clarification. Could you please let me know what files you have in the directory where the notebook file is?

edsml-sb3323 commented 1 year ago

Thank you for your reply. Here is the list attached image

marijanbeg commented 1 year ago

Could you try adding the following two lines before the import statement?

import sys
sys.path.append("./")
edsml-sb3323 commented 1 year ago

I think I found the error, if I try running the import statements outside lecture1 dir, this error comes up.

I tried running the import statements by creating a new notebook inside lecture1 dir and it worked. Thank you for your assistance !

image

image

marijanbeg commented 1 year ago

Exactly, as we said earlier, lecture.py must be in the same directory as the notebook you are running. I am closing this issue now.