# Find source of Deprecation warning

**URL:** <https://forum.ansible.com/t/find-source-of-deprecation-warning/46081>\
**Category:** Get Help\
**Tags:** azure, kubernetes, windows, vmware, aws, deprecation, network, galaxy-ng\
**Created:** [July 24, 2026, 10:53am UTC](https://forum.ansible.com/t/find-source-of-deprecation-warning/46081 "2026-07-24T10:53:09Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gaetan](https://avatars.discourse-cdn.com/v4/letter/g/b77776/32.png) [@Gaetan](https://forum.ansible.com/u/Gaetan)\
**Post date:** [July 24, 2026, 10:53am UTC](https://forum.ansible.com/t/find-source-of-deprecation-warning/46081/1 "2026-07-24T10:53:09Z")

</div>

Hello,  
I am running ansible 2.21 on a Debian 13. Whenever I run Ansible, I get a deprecation warning. None of my playbooks use that deprecated function and the warning shows up no matter what arguments I give it (even no arguments or --version or --help). I have updated ansible’s own collections but the message persists.

Here is the message:

```auto
[WARNING]: Deprecation warnings can be disabled by setting `deprecation_warnings=False` in ansible.cfg.
[DEPRECATION WARNING]: Importing 'to_text' from 'ansible.module_utils._text' is deprecated. This feature will be removed from ansible-core version 2.24. Use ansible.module_utils.common.text.converters instead.

```

Here’s what --version has to say:

```auto
ansible [core 2.21.2]
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/myuser/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3/dist-packages/ansible
  ansible collection location = /home/myuser/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/local/bin/ansible
  python version = 3.13.5 (main, Jul 15 2026, 20:25:40) [GCC 14.2.0] (/usr/bin/python3)
  jinja version = 3.1.6
  pyyaml version = 6.0.2 (with libyaml v0.2.5)

```

And here is the result of `ansible-galaxy collection list`:

```auto

# /home/myuser/.ansible/collections/ansible_collections
Collection Version
---------------------------------------- -------
ansible.netcommon 8.6.0  
ansible.posix 2.2.2  
ansible.utils 6.0.3  
ansible.windows 3.7.0  
community.general 13.2.0 

# /usr/lib/python3/dist-packages/ansible/_internal/ansible_collections
Collection Version
---------------------------------------- -------
ansible._protomatter *      

# /usr/lib/python3/dist-packages/ansible_collections
Collection Version
---------------------------------------- -------
amazon.aws 11.4.0 
ansible.mysql 5.1.0  
ansible.netcommon 8.6.0  
ansible.posix 2.2.2  
ansible.utils 6.0.3  
ansible.windows 3.7.0  
arista.eos 12.1.2 
azure.azcollection 3.20.0 
check_point.mgmt 6.9.0  
chocolatey.chocolatey 1.6.0  
cisco.aci 2.13.0 
cisco.intersight 2.20.0 
cisco.ios 11.4.2 
cisco.iosxr 12.3.2 
cisco.meraki 2.24.1 
cisco.mso 2.13.0 
cisco.nxos 11.2.0 
cisco.ucs 1.16.0 
cloudscale_ch.cloud 2.5.3  
community.aws 11.1.0 
community.ciscosmb 1.0.12 
community.clickhouse 2.3.0  
community.crypto 3.3.0  
community.dns 4.0.2  
community.docker 5.2.1  
community.general 13.2.0 
community.grafana 2.3.0  
community.hashi_vault 7.1.0  
community.hrobot 2.7.2  
community.library_inventory_filtering_v1 1.1.5  
community.libvirt 2.3.0  
community.mongodb 1.8.0  
community.mysql 5.0.2  
community.okd 5.0.0  
community.postgresql 4.2.0  
community.proxmox 2.0.0  
community.proxysql 1.8.0  
community.rabbitmq 1.7.0  
community.routeros 3.21.0 
community.sap_libs 1.7.0  
community.sops 2.4.0  
community.vmware 6.2.1  
community.windows 3.3.0  
community.zabbix 4.2.0  
containers.podman 1.20.2 
cyberark.conjur 1.3.12 
cyberark.pas 1.0.39 
dellemc.enterprise_sonic 4.1.0  
dellemc.openmanage 10.0.3 
dellemc.powerflex 3.1.0  
dellemc.unity 2.1.0  
f5networks.f5_modules 1.42.0 
fortinet.fortimanager 2.14.0 
fortinet.fortios 2.5.1  
google.cloud 1.13.0 
grafana.grafana 6.1.0  
graphiant.naas 26.6.0 
hetzner.hcloud 6.10.0 
hitachivantara.vspone_block 4.8.2  
hitachivantara.vspone_object 1.2.0  
ibm.storage_virtualize 3.3.0  
ieisystem.inmanage 4.0.0  
infinidat.infinibox 1.8.1  
infoblox.nios_modules 1.9.0  
inspur.ispim 2.2.4  
kaytus.ksmanage 4.0.0  
kubernetes.core 6.5.0  
kubevirt.core 2.3.0  
lowlydba.sqlserver 2.8.1  
microsoft.ad 1.12.0 
microsoft.iis 1.2.1  
netapp.cloudmanager 21.24.0
netapp.ontap 23.5.0 
netapp.storagegrid 21.16.0
netapp_eseries.santricity 2.0.1  
netbox.netbox 3.23.0 
ngine_io.cloudstack 3.0.0  
openstack.cloud 2.6.0  
ovirt.ovirt 3.2.2  
pcg.alpaca_operator 2.2.0  
purestorage.flasharray 1.43.0 
purestorage.flashblade 1.26.0 
ravendb.ravendb 1.0.4  
splunk.es 6.0.1  
telekom_mms.icinga_director 2.5.1  
theforeman.foreman 5.11.0 
vmware.vmware 2.9.0  
vmware.vmware_rest 4.11.0 
vultr.cloud 1.14.1 
vyos.vyos 6.0.0  
wti.remote 1.0.11 

```

Where can I find out where the deprecation is coming from and fix it?  
Thank you

---

<div class="post-metadata">

**Author:** ![felixfontein](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/felixfontein/32/7530_2.png) [@felixfontein](https://forum.ansible.com/u/felixfontein)\
**Post date:** [July 24, 2026, 10:55am UTC](https://forum.ansible.com/t/find-source-of-deprecation-warning/46081/2 "2026-07-24T10:55:17Z")

</div>

You can use [Ansible Configuration Settings — Ansible Core Documentation](https://docs.ansible.com/projects/ansible-core/devel/reference_appendices/config.html#display-traceback) and set the option to `deprecated`, then you will get a stack trace and can see which plugin caused the deprecation.

Usually looking at the task which triggers the deprecation also provides that information. It’s likely some collection that hasn’t fixed these imports yet.

---

<div class="post-metadata">

**Author:** ![Gaetan](https://avatars.discourse-cdn.com/v4/letter/g/b77776/32.png) [@Gaetan](https://forum.ansible.com/u/Gaetan)\
**Post date:** [July 24, 2026, 11:35am UTC](https://forum.ansible.com/t/find-source-of-deprecation-warning/46081/3 "2026-07-24T11:35:16Z")

</div>

Thanks, indeed I get more details like that.

Here’s what the trace says:

```auto
Traceback (most recent call last):
  File "/usr/local/bin/ansible", line 36, in <module>
    from ansible.module_utils._text import to_text
  File "/usr/lib/python3/dist-packages/ansible/module_utils/_text.py", line 30, in __getattr__
    _warnings.deprecate(
Message: Importing 'to_text' from 'ansible.module_utils._text' is deprecated.

```

I can indeed see that the deprecated import is present in the /usr/local/bin/ansible file, but I’m a bit confused because this is part of Ansible itself and I already have the latest version available on apt, i.e 2.21.2-1ppa~noble

 ![image](https://us1.discourse-cdn.com/ansible/original/2X/5/5ee9abab5f2c2663164e895ce857a141e17811b1.png)

---

<div class="post-metadata">

**Author:** ![bcoca](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/bcoca/32/9269_2.png) [@bcoca](https://forum.ansible.com/u/bcoca)\
**Post date:** [July 24, 2026, 3:04pm UTC](https://forum.ansible.com/t/find-source-of-deprecation-warning/46081/4 "2026-07-24T15:04:29Z")

</div>

You are mixing ansible versions, your ansible executable is a much older version than the module\_utils, Python 2 support was removed long ago, so the script you are showing is not the one shipped with 2.21.

---

<div class="post-metadata">

**Author:** ![felixfontein](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/felixfontein/32/7530_2.png) [@felixfontein](https://forum.ansible.com/u/felixfontein)\
**Post date:** [July 24, 2026, 9:04pm UTC](https://forum.ansible.com/t/find-source-of-deprecation-warning/46081/5 "2026-07-24T21:04:01Z")

</div>

Yeah, this looks like it’s from a very old ansible-core version. Likely even pre-ansible-core, since even Ansible 2.9 didn’t support Python 2.6 on the controller.

If this file comes from a system package / PPA, you should be able to use `dpkg -S /usr/local/bin/ansible` to figure out which package it comes from.

---

<div class="post-metadata">

**Author:** ![Gaetan](https://avatars.discourse-cdn.com/v4/letter/g/b77776/32.png) [@Gaetan](https://forum.ansible.com/u/Gaetan)\
**Post date:** [August 11, 2026, 9:52am UTC](https://forum.ansible.com/t/find-source-of-deprecation-warning/46081/6 "2026-08-11T09:52:03Z")

</div>

Thanks. That’s kind of weird. I’ve tried running the dpkg command but it doesn’t seem to return anything:

```auto
dpkg-query: no path found matching pattern /usr/local/bin/ansible

```

If I run just `dpkg -S bin/ansible` I get this:

```auto
ansible-core: /usr/bin/ansible-config
ansible-core: /usr/bin/ansible-galaxy
ansible-core: /usr/bin/ansible-doc
ansible: /usr/bin/ansible-community
ansible-core: /usr/bin/ansible-vault
ansible-core: /usr/bin/ansible-pull
ansible-core: /usr/bin/ansible
ansible-core: /usr/bin/ansible-inventory
ansible-core: /usr/bin/ansible-playbook
ansible-core: /usr/bin/ansible-console
ansible-core: /usr/bin/ansible-test
ansible-lint: /usr/bin/ansible-lint

```

So I only have ansible (14.2.0), ansible-core (2.21.2) and ansible-lint (25.6.1) installed.

I wonder what this /usr/local/bin/ansible folder is about…

---

<div class="post-metadata">

**Author:** ![Soufiane\_CHEHBOUNE](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/soufiane_chehboune/32/11031_2.png) [@Soufiane\_CHEHBOUNE](https://forum.ansible.com/u/Soufiane_CHEHBOUNE)\
**Post date:** [August 11, 2026, 3:27pm UTC](https://forum.ansible.com/t/find-source-of-deprecation-warning/46081/7 "2026-08-11T15:27:25Z")

</div>

I suggest to use python env and install ansible inside , rather to install it directly on debian

---

<div class="post-metadata">

**Author:** ![Gaetan](https://avatars.discourse-cdn.com/v4/letter/g/b77776/32.png) [@Gaetan](https://forum.ansible.com/u/Gaetan)\
**Post date:** [August 26, 2026, 7:47am UTC](https://forum.ansible.com/t/find-source-of-deprecation-warning/46081/8 "2026-08-26T07:47:39Z")

</div>

Thanks, I think that’s what I’ll do. Do I need to uninstall ansible from apt before installing it with pip or can both versions cohabit for a while?

---

<div class="post-metadata">

**Author:** ![Soufiane\_CHEHBOUNE](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/soufiane_chehboune/32/11031_2.png) [@Soufiane\_CHEHBOUNE](https://forum.ansible.com/u/Soufiane_CHEHBOUNE)\
**Post date:** [August 26, 2026, 8:09am UTC](https://forum.ansible.com/t/find-source-of-deprecation-warning/46081/9 "2026-08-26T08:09:06Z")

</div>

I prefer uninstall ansible completly from apt , use ansible inside venv python only to avoid issues

---

<div class="post-metadata">

**Author:** ![Gaetan](https://avatars.discourse-cdn.com/v4/letter/g/b77776/32.png) [@Gaetan](https://forum.ansible.com/u/Gaetan)\
**Post date:** [August 27, 2026, 7:57am UTC](https://forum.ansible.com/t/find-source-of-deprecation-warning/46081/10 "2026-08-27T07:57:01Z")

</div>

Thanks. I’ve ran `apt remove ansible`, followed by `pipx install ansible`, but I’m a bit confused at the results as it doesn’t seem to have done much…  
Here are the results of ansible --version now, it is the same as what I originally posted:

```auto
[WARNING]: Deprecation warnings can be disabled by setting `deprecation_warnings=False` in ansible.cfg.
[DEPRECATION WARNING]: Importing 'to_text' from 'ansible.module_utils._text' is deprecated. This feature will be removed from ansible-core version 2.24. Use ansible.module_utils.common.text.converters instead.

Traceback (most recent call last):
  File "/usr/local/bin/ansible", line 36, in <module>
    from ansible.module_utils._text import to_text
  File "/usr/lib/python3/dist-packages/ansible/module_utils/_text.py", line 30, in __getattr__
    _warnings.deprecate(
Message: Importing 'to_text' from 'ansible.module_utils._text' is deprecated.

ansible [core 2.21.3]
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/myuser/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3/dist-packages/ansible
  ansible collection location = /home/myuser/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/local/bin/ansible
  python version = 3.13.5 (main, Jul 15 2026, 20:25:40) [GCC 14.2.0] (/usr/bin/python3)
  jinja version = 3.1.6
  pyyaml version = 6.0.2 (with libyaml v0.2.5)

```

---

<div class="post-metadata">

**Author:** ![bcoca](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/bcoca/32/9269_2.png) [@bcoca](https://forum.ansible.com/u/bcoca)\
**Post date:** [August 27, 2026, 5:55pm UTC](https://forum.ansible.com/t/find-source-of-deprecation-warning/46081/11 "2026-08-27T17:55:00Z")

</div>

Your `/usr/local/bin/ansible` location is probably not the result of a packged install, neither `pip` nor `apt` are likely to do so. I suspect some manual or scripted installed that does not use any of the conventions of those packaging systems, so removing/adding packages will probably not solve it.

I see 2 solutions:

- find and reverse engineer the previous install in the hope of fixing or removing it
- start from scratch with a clean OS, then use either `apt/pip/dnf/etc` to install `ansible` and stick with the method chosen.

---

<div class="post-metadata">

**Author:** ![Gaetan](https://avatars.discourse-cdn.com/v4/letter/g/b77776/32.png) [@Gaetan](https://forum.ansible.com/u/Gaetan)\
**Post date:** [September 1, 2026, 8:29am UTC](https://forum.ansible.com/t/find-source-of-deprecation-warning/46081/12 "2026-09-01T08:29:15Z")

</div>

Thanks. I ended up doing a manual cleanup and installing with pipx. Looks like it worked:

```auto
 ansible --version

ansible [core 2.21.3]
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/myuser/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/myuser/.local/pipx/venvs/ansible/lib/python3.13/site-packages/ansible
  ansible collection location = /home/myuser/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/myuser/.local/bin/ansible
  python version = 3.13.5 (main, Jul 15 2026, 20:25:40) [GCC 14.2.0] (/home/myuser/.local/pipx/venvs/ansible/bin/python)
  jinja version = 3.1.6
  pyyaml version = 6.0.3 (with libyaml v0.2.5)

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [October 1, 2026, 8:29am UTC](https://forum.ansible.com/t/find-source-of-deprecation-warning/46081/13 "2026-10-01T08:29:50Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
