Unexpected Exception: name ‘basestring’ is not defined when invoking ansible2


I’m trying to execute ansible2 commnads…

When I do:

I get:

Unexpected Exception: name ‘basestring’ is not defined
the full traceback was:

Here is ansible --version:

And here is python --version


Ansible below version 2.5 requires Python 2.6 or 2.7 on the control host: Control Node Requirements

basestring is no longer available in Python 3. From What’s New In Python 3.0:

The builtin basestring abstract type was removed. Use str instead. The str and bytes types don’t have functionality enough in common to warrant a shared base class. The 2to3 tool (see below) replaces every occurrence of basestring with str.

So the solution is to either upgrade Ansible or downgrade Python.

Leave a Reply