ImportError: cannot import name 'AnsibleCollectionLoader'

when run : $ sudo python3 install.py --develop --site erp.anas.com --user anas --bench-name bench --verbose

Requirement already satisfied: MarkupSafe>=0.23 in /usr/local/lib64/python3.6/site-packages (from jinja2->ansible==2.8.5) (1.1.1)
WARNING: Running pip as the ‘root’ user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
ERROR! Unexpected Exception, this is probably a bug: cannot import name ‘AnsibleCollectionLoader’
the full traceback was:

Traceback (most recent call last):
File “/usr/local/bin/ansible-playbook”, line 90, in
mycli = getattr(import(“ansible.cli.%s” % sub, fromlist=[myclass]), myclass)
File “/usr/local/lib/python3.6/site-packages/ansible/cli/init.py”, line 22, in
from ansible.inventory.manager import InventoryManager
File “/usr/local/lib/python3.6/site-packages/ansible/inventory/manager.py”, line 38, in
from ansible.plugins.loader import inventory_loader
File “/usr/local/lib/python3.6/site-packages/ansible/plugins/loader.py”, line 26, in
from ansible.utils.collection_loader import AnsibleCollectionLoader, AnsibleFlatMapLoader, is_collection_ref
ImportError: cannot import name ‘AnsibleCollectionLoader’
Traceback (most recent call last):
File “install.py”, line 437, in
install_bench(args)
File “install.py”, line 211, in install_bench
run_playbook(‘create_user.yml’, extra_vars=extra_vars)
File “install.py”, line 362, in run_playbook
success = subprocess.check_call(args, cwd=os.path.join(cwd, ‘playbooks’), stdout=log_stream, stderr=sys.stderr)
File “/usr/lib64/python3.6/subprocess.py”, line 311, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command ‘[’/usr/local/bin/ansible-playbook’, ‘-c’, ‘local’, ‘create_user.yml’, ‘-vvvv’, ‘-e’, ‘@/tmp/extra_vars.json’]’ returned non-zero exit status 250.

try this command

  1. pip3 uninstall ansible
  2. rm -rf /usr/local/lib/python3.7/site-packages/ansible
  3. pip3 install ansible