Frequently Asked Questions

Here are some frequently asked questions regarding troubleshooting your assignments.

Failing in the Autograder

Here are some common reasons why you might succeed locally but not in the autograder:

Calling exit()

If you call exit() anywhere in your code it will cause pytest to hard exit. Remove the exit() statement and try to find a clever way to accomplish the same thing.

Extra import statements

If you are getting an error similar to ModuleNotFoundError: No module named [insert module here], you might have an extraneous import statement in your code. Simply remove the extra import and try again.

Note

Some of the completions that Visual Studio Code or PyCharm suggest will automatically attempt to import modules for you. You might have to manually remove any unwanted import statements before you submit.

Disabling auto-import in VS Code

To disable auto-import completions, press Ctrl+Shift+P (on macOS type Cmd+Shift+P), type open settings, select “Open User Settings (JSON)”, and add this line to the bottom before the } to disable auto-import completions:

"python.analysis.autoImportCompletions": false

You can also select “Open Settings (UI)”, search for python.analysis.autoImportCompletions, and uncheck the box.

Disabling auto-import in PyCharm

For information on how to disable auto-import in PyCharm see here.

Opening a file that does not exist

Double check that you didn’t leave any extraneous testing code in your files that is trying to open a file on your local machine. This often happens when you are testing your code while writing it and it is easy to forget to remove those lines.

Hard coding a file path

Double check that you didn’t manually specify any paths to files in your code. Generally you should only need to provide the file name when opening a file.

Assignments

Lab 01

Error: input was called too many times

If you are getting output that contains:

raise Exception("input() called more times than expected")

you are probably prompting the user for too much information.

Double check the directions for what order / when you should prompt the user: Q3: Mad Libs