# issue in installation of ansible

**URL:** <https://forum.ansible.com/t/issue-in-installation-of-ansible/36289>\
**Category:** Ansible Project\
**Tags:** ubuntu\
**Created:** [February 4, 2022, 2:08am UTC](https://forum.ansible.com/t/issue-in-installation-of-ansible/36289 "2022-02-04T02:08:25Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kevin\_Y](https://avatars.discourse-cdn.com/v4/letter/k/b2d939/32.png) [@Kevin\_Y](https://forum.ansible.com/u/Kevin_Y)\
**Post date:** [February 4, 2022, 2:08am UTC](https://forum.ansible.com/t/issue-in-installation-of-ansible/36289/1 "2022-02-04T02:08:25Z")

</div>

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’

---

<div class="post-metadata">

**Author:** ![jcpetro](https://avatars.discourse-cdn.com/v4/letter/j/53a042/32.png) [@jcpetro](https://forum.ansible.com/u/jcpetro)\
**Post date:** [February 4, 2022, 2:11am UTC](https://forum.ansible.com/t/issue-in-installation-of-ansible/36289/2 "2022-02-04T02:11:50Z")

</div>

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

–John

---

<div class="post-metadata">

**Author:** ![Kevin\_Y](https://avatars.discourse-cdn.com/v4/letter/k/b2d939/32.png) [@Kevin\_Y](https://forum.ansible.com/u/Kevin_Y)\
**Post date:** [February 4, 2022, 3:01am UTC](https://forum.ansible.com/t/issue-in-installation-of-ansible/36289/3 "2022-02-04T03:01:52Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Nico\_Kadel-Garcia](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/nico_kadel-garcia/32/9998_2.png) [@Nico\_Kadel-Garcia](https://forum.ansible.com/u/Nico_Kadel-Garcia)\
**Post date:** [February 4, 2022, 3:53am UTC](https://forum.ansible.com/t/issue-in-installation-of-ansible/36289/4 "2022-02-04T03:53:49Z")

</div>

> 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.

---

<div class="post-metadata">

**Author:** ![vbotka](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/vbotka/32/359_2.png) [@vbotka](https://forum.ansible.com/u/vbotka)\
**Post date:** [February 4, 2022, 4:50am UTC](https://forum.ansible.com/t/issue-in-installation-of-ansible/36289/5 "2022-02-04T04:50:36Z")

</div>

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

ansible 5.2.0, installed by \*apt\*, provides

&nbsp;&nbsp;/usr/lib/python3/dist-packages/ansible/context.py  
&nbsp;&nbsp;/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

&nbsp;&nbsp;/usr/local/lib/python3.8/dist-packages

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

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

, but 'ansible.module\_utils' are missing in

&nbsp;&nbsp;/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](https://askubuntu.com/questions/431780/apt-get-install-vs-pip-install)

---

<div class="post-metadata">

**Author:** ![vbotka](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/vbotka/32/359_2.png) [@vbotka](https://forum.ansible.com/u/vbotka)\
**Post date:** [February 4, 2022, 5:07am UTC](https://forum.ansible.com/t/issue-in-installation-of-ansible/36289/6 "2022-02-04T05:07:14Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Kevin\_Y](https://avatars.discourse-cdn.com/v4/letter/k/b2d939/32.png) [@Kevin\_Y](https://forum.ansible.com/u/Kevin_Y)\
**Post date:** [February 5, 2022, 1:31am UTC](https://forum.ansible.com/t/issue-in-installation-of-ansible/36289/7 "2022-02-05T01:31:04Z")

</div>

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!!
