import logging


def select_python_venv(py_venvs, tox_dir):
    """
    Get user input to select one of the available
    Python venv(s)
    """
    logging.info('There are more than one amiable Python venv(s) in the .tox dir.')
    while True:
        print(f"\n\nPick one of the available python venv(s) in '{tox_dir}'.")
        for i, penv in enumerate(py_venvs):
            print(i, penv)

        index = input('Enter the index of the python venv you want: ')
        try:
            py_venv = py_venvs[int(index)]
            return py_venv
        except Exception as exc:
            print('\nException:\n', str(exc))
            print(f'error: {index} is not a valid index. Please try again...')