How to Solve NameError: name 'shlex' is not defined

Solution: Import the 'shlex' module

# Add the following line to the top of your code
import shlex

 

For more information:
Python shlex