Frequently Asked Questions

Here are some frequently asked questions regarding troubleshooting your assignments.

General Issues

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.

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

Failing in the Autograder

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

Extraneous imports in your code

If you are getting an error similar to ModuleNotFoundError: No module named [insert module here], you might have an extraneous import in your code. Simply remove the 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 imports before you submit.

Disabling auto-import 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 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.