issue in installation of ansible

Hi Ubuntu is installed at windows10 and then the below commands are entered in the Ubunto. It looks like the installing ansible is successful without error message.

$ sudo apt-get update
$ sudo apt-get install software-properties-common
$ sudo apt-add-repository ppa:ansible/ansible
$ sudo apt-get update
$ sudo apt-get install ansible -y

However, the installation mayby unsuccessful because we can see below message with command “ansible -v”. Please see the below. Did I miss some step for the installation? Anyone can help for this? Thank you

admin1@Le:~$ ansible -v
Traceback (most recent call last):
File “/usr/bin/ansible”, line 44, in
from ansible import context
File “/usr/local/lib/python3.8/dist-packages/ansible/context.py”, line 18, in
from ansible.module_utils.common._collections_compat import Mapping, Set
ModuleNotFoundError: No module named ‘ansible.module_utils’

Is python 3.8 installed? If not, you might want to try that

–John

Thank you John for your reply!
Python3.8 is installed. I can see it with below command:

admin1@Le:~$ python3 --version
Python 3.8.10

Hi Ubuntu is installed at windows10 and then the below commands are entered in the Ubunto. It looks like the installing ansible is successful without error message.

$ sudo apt-get update
$ sudo apt-get install software-properties-common
$ sudo apt-add-repository ppa:ansible/ansible
$ sudo apt-get update
$ sudo apt-get install ansible -y

This may sound like a broken record, I've personally tried to help
peopole walk through this before. The "ansible" no longer contains nor
provides any functional component of the old "ansible" software, those
are now published as a tarball called "ansible-core", which is very
confusing. I suspect you need to clear away old copies or update your
copy of "ansible-core".

Also, "Ubuntu is installed at Windows 10" does not mean you're
actually getting the Ubuntu provided version of everything unless
you're running in a VM or profoundly separated environment. Windows
can have its own python installed, and being sure you got the right
one and marged them cleanly can be..... well, an adventure.

However, the installation mayby unsuccessful because we can see below message with command "ansible -v". Please see the below. Did I miss some step for the installation? Anyone can help for this? Thank you

admin1@Le:~$ ansible -v
Traceback (most recent call last):

The "ansible" script and all its modules are in the "ansible-core"
package. You might simply discard the "ansible" package altogether and
use only "ansible-core" and see if it works for you. I've been
publishing .spec files to package up this stuff for RHEL based
operating systems, it's confusing over there as well.

You're mixing *pip* and *apt* installation, I guess.

ansible 5.2.0, installed by *apt*, provides

  /usr/lib/python3/dist-packages/ansible/context.py
  /usr/lib/python3/dist-packages/ansible/module_utils/common/_collections_compat.py

In Ubuntu 20.04, the packages ansible 5.2.0 and ansible-core 2.12.1,
installed by *apt*, put no files into the directory

  /usr/local/lib/python3.8/dist-packages

Instead, your *ansible*, probably installed by *pip*, is running

  /usr/local/lib/python3.8/dist-packages/ansible/context.py

, but 'ansible.module_utils' are missing in

  /usr/local/lib/python3.8/dist-packages/

The fastest solution would be probably to purge all *pip* and *apt*
ansible packages and reinstall them by *apt*. You can find more
details in
https://askubuntu.com/questions/431780/apt-get-install-vs-pip-install

The option '-v' means verbose. Try '--version' instead. You should
see the paths (e.g. ansible 5.2.0 installed by *apt*)

ansible python module location = /usr/lib/python3/dist-packages/ansible

there are two issues. first, after reinstalling, the issue is resolved, second, correct command is “ansible --version”. the reason that i used “ansible --v” is it worked before. but after reinstalling, the command cannot work
Thank all of you!!