NameError: name 'exit' is not defined

Solution 1:

Importing sys will not be enough to make exit live in the global scope.

You either need to do

from sys import exit
exit()

or

import sys
sys.exit()

Note that, as you are also using argv, in the first case you should do from sys import argv,exit

Solution 2:

You have to apply the function to sys:

from sys import exit
exit()

because exit is the function itself, you need to call it with ()