How to Solve NameError: name 'ensure_dir' is not defined -- pip

Solution: Import the 'ensure_dir' module

# Add the following line to the top of your code
from pip._internal.utils.misc import ensure_dir

 

For more information:
pip ensure_dir