Struggling with grader recognizing code that runs


I’m experiencing some frustration as 9/10 Coursera submissions for assignment 4 give me the error “There was a problem compiling the code from your notebook. Details: [Errno 2] No such file or directory: ‘’” in both train_happy_sad_model and image_generator.
The code (and variations of it) have all run smoothly within Coursera’s Jupyter interface, but the grader is always stuck on that part, for some reason.

I’ve done some troubleshooting by:

  1. Changing the path name to a directory on my computer, which it also never recognizes,
  2. Uploading the dowloaded .zip directly into my Coursera-Jupyter work files, and
  3. Attempting to tweak my code based on mentor-provided resources on a similar thread as well as googling similar questions.

Here’s a google CoLab version of my most recent submission attempt: [code removed - moderator]

Thanks in advance for your help!

Please use the coursera environment for solving the assignment if you are having problems setting up local environment correctly.
base_dir was not set correctly after downloading the zip file.
Here’s the trace from your notebook:

FileNotFoundError                         Traceback (most recent call last)
<ipython-input-10-8a441476e15b> in <module>()
      7 print("Sample happy image:")
----> 8 plt.imshow(load_img(f"{os.path.join(happy_dir, os.listdir(happy_dir)[0])}"))

FileNotFoundError: [Errno 2] No such file or directory: ''

Here’s my most recently submitted code: [code removed - moderator]
This runs very well in Google CoLab as well as the Coursera environment.

I’ve been working entirely within Coursera, and the code always runs and provides all expected outputs. I’ve updated my code several times, and am concerned about what directories the Coursera grading is looking at.

My most recent error message was “There was a problem compiling the code from your notebook. Details: [Errno 2] No such file or directory: ‘/grader/’” - after I uploaded the .zip to the Coursera environment , and correctly pointed to it using this code snippet:

    path = f"{getcwd()}/"
    zip_ref = zipfile.ZipFile(path, 'r')

Here are my lab files for reference:

[code removed - moderator]

I have also attempted using this code snippet:

!wget --no-check-certificate \
    "" \
    -O "/tmp/"

zip_ref = zipfile.ZipFile("/tmp/", 'r')

Unfortunately, I get the error message: “There was a problem compiling the code from your notebook. Details: [Errno 2] No such file or directory: ‘/tmp/’”. This happens even if the Coursera lab environment creates the tmp/ from the download and runs correctly.

The code breaks if I try to direct it to any files on my computer, so I’m just very stuck on what .zip file the grader is supposed to be able to see and work with.

The data you need for this assignment is present in these locations:

happy_dir = "./data/happy/"
sad_dir = "./data/sad/"

The grader evaluates your code with respect to these locations and not your zip file. Do not download zip file(s). Fill your code with respect to the notebook. Don’t hardcode paths. Use function parameters when they are provided.

1 Like

Thank you so much - I just chucked the code entirely and fixed my flow from directory. All passed!