issue in installation of ansible

702 views
Skip to first unread message

Kevin Y

unread,
Feb 3, 2022, 9:08:25 PM2/3/22
to Ansible Project

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 <module>
    from ansible import context
  File "/usr/local/lib/python3.8/dist-packages/ansible/context.py", line 18, in <module>
    from ansible.module_utils.common._collections_compat import Mapping, Set
ModuleNotFoundError: No module named 'ansible.module_utils'



John Petro

unread,
Feb 3, 2022, 9:12:18 PM2/3/22
to ansible...@googlegroups.com
Is python 3.8 installed?  If not, you might want to try that

--John

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/981a6842-ce60-4b79-bcca-5236900eae4en%40googlegroups.com.

Kevin Y

unread,
Feb 3, 2022, 10:01:52 PM2/3/22
to Ansible Project
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

Nico Kadel-Garcia

unread,
Feb 3, 2022, 10:54:11 PM2/3/22
to ansible...@googlegroups.com
On Thu, Feb 3, 2022 at 9:08 PM Kevin Y <kyint...@gmail.com> wrote:
>
> 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.

Vladimir Botka

unread,
Feb 3, 2022, 11:51:04 PM2/3/22
to Kevin Y, ansible...@googlegroups.com
On Thu, 3 Feb 2022 18:08:25 -0800 (PST)
Kevin Y <kyint...@gmail.com> wrote:

> .. Ubuntu
>
> $ sudo apt-get install ansible -y
>
> admin1@Le:~$ ansible -v
> Traceback (most recent call last):
> File "/usr/bin/ansible", line 44, in <module>
> from ansible import context
> File "/usr/local/lib/python3.8/dist-packages/ansible/context.py", line
> 18, in <module>
> from ansible.module_utils.common._collections_compat import Mapping, Set
> ModuleNotFoundError: No module named 'ansible.module_utils'

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


--
Vladimir Botka

Vladimir Botka

unread,
Feb 4, 2022, 12:07:42 AM2/4/22
to Kevin Y, ansible...@googlegroups.com
On Thu, 3 Feb 2022 18:08:25 -0800 (PST)
Kevin Y <kyint...@gmail.com> wrote:

> admin1@Le:~$ ansible -v

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


--
Vladimir Botka

Kevin Y

unread,
Feb 4, 2022, 8:30:55 PM2/4/22
to Vladimir Botka, ansible...@googlegroups.com
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!!
Reply all
Reply to author
Forward
0 new messages