csce585-mlsystems / project-athena

This is the course project for CSCE585: ML Systems. Students will build their machine learning systems based on the provided infrastructure --- Athena.
MIT License
13 stars 19 forks source link

Helping with the ``ModuleNotFoundError`` #26

Closed ShugeLei closed 4 years ago

ShugeLei commented 4 years ago

Hello everyone,

I have followed all Ying's instructions, yet I still have such problems: ### ModuleNotFoundError: No module named 'utils.model'. It seems like I always have such problems when ### importing the module under the package.

I tried the method as below, add an init.py under the package utils, yet it still did not work. Do you know what’s wrong with my work? ( We have discussed in our team, we can’t solve the problem yet. Two of our members met such problems.)

Thanks, Shuge

image image

Python 3.7.6 (default, Jan 8 2020, 13:42:34) Type "copyright", "credits" or "license" for more information.

IPython 7.18.1 -- An enhanced Interactive Python.

runfile('/Users/shugelei/Desktop/2020Fall/CSCE585/project-athena-master/src/tutorials/craft_adversarial_examples.py', wdir='/Users/shugelei/Desktop/2020Fall/CSCE585/project-athena-master/src/tutorials') Traceback (most recent call last):

File "/Users/shugelei/Desktop/2020Fall/CSCE585/project-athena-master/src/tutorials/craft_adversarial_examples.py", line 12, in from utils.model import load_lenet

### ModuleNotFoundError: No module named 'utils.model'

MENG2010 commented 4 years ago

I just double-checked my local project, all updates for Task 2 have been committed and pushed to the GitHub. And the scripts work correctly here.

From the description, I cannot get enough info to replicate your problem.

My suggestions would be:

  1. Make sure that your scripts have been updated from GitHub.
  2. Run the craft_adversarial_examples.py by clicking the run button (the green triangle if you are using PyCharm).

image

For Jupyter notebook, before you enter the notebook. you need to activate the proper environment first.

One question for you, why you did not encounter this issue when working on Task 1?

Dojones98 commented 4 years ago

I think this issue may be solved by setting your root directory to the '/src' directory. In Pycharm, try right-clicking on the /src folder -> mark directory as -> mark sources root. I'm not sure if those buttons are named exactly that, but that is the general process. Let me know if this helps @ShugeLei or if you have already done this.

MENG2010 commented 4 years ago

Thanks @Dojone98!

ShugeLei commented 4 years ago

@MENG2010 @Dojones98 Thanks for your prompt response! I appreciate it so much. Let me work on it based on your suggestions and see what's going on.

MENG2010 commented 4 years ago

If you prefer to run the script from the terminal using a command line, appending the parent directory to the path. image

MENG2010 commented 4 years ago

I just added the parent directory to the path, so all the python tutorials should be able to run correctly via terminal. Please check the latest commitments.

MENG2010 commented 4 years ago

problem solved.