# Pip module does nothing when state=absent

**URL:** <https://forum.ansible.com/t/pip-module-does-nothing-when-state-absent/27317>\
**Category:** Ansible Project\
**Created:** [April 18, 2018, 8:59pm UTC](https://forum.ansible.com/t/pip-module-does-nothing-when-state-absent/27317 "2018-04-18T20:59:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Guy\_Knights](https://avatars.discourse-cdn.com/v4/letter/g/db5fbb/32.png) [@Guy\_Knights](https://forum.ansible.com/u/Guy_Knights)\
**Post date:** [April 18, 2018, 8:59pm UTC](https://forum.ansible.com/t/pip-module-does-nothing-when-state-absent/27317/1 "2018-04-18T20:59:56Z")

</div>

I recently upgraded to Ansible 2.4 and have run into a weird problem. I added a task to remove a python package that was breaking pip on one of our servers, the task is below:

- name: Remove pip package ndg-httpsclient as it breaks pip  
pip:  
name: ndg-httpsclient  
state: absent

When this task is run on a server that definitely has ndg-httpsclient installed (as per pip freeze), it does not register a change. If I check the package list after the run, it’s still listed as installed (and pip is still broken).

Here’s a screenshot of the output of pip freeze before the ansible run:

[![](https://lh3.googleusercontent.com/-Mq2uxZVLrZc/WtexMOrAZHI/AAAAAAAAEGE/CsZt-f13YZYF5WauLMa7Xp0EPTI3XyEkwCLcBGAs/s1600/server_pip_package_before.png)](https://lh3.googleusercontent.com/-Mq2uxZVLrZc/WtexMOrAZHI/AAAAAAAAEGE/CsZt-f13YZYF5WauLMa7Xp0EPTI3XyEkwCLcBGAs/s1600/server_pip_package_before.png)

Here’s the task output from the ansible run:

[![](https://lh3.googleusercontent.com/-p3L_npDnAds/WtexbLkOMiI/AAAAAAAAEGI/0VUahB4zDlQEfB1UJzK_PxNaVZ48mjIvwCLcBGAs/s1600/ansible_pip_run.png)](https://lh3.googleusercontent.com/-p3L_npDnAds/WtexbLkOMiI/AAAAAAAAEGI/0VUahB4zDlQEfB1UJzK_PxNaVZ48mjIvwCLcBGAs/s1600/ansible_pip_run.png)

Here’s the output of pip freeze after the run:

[![](https://lh3.googleusercontent.com/-Fz8xHE_bUKg/Wtexi3V7spI/AAAAAAAAEGM/b25LdhMcMPgZZHYhNT-byOr3LChwOvB1gCLcBGAs/s1600/server_pip_package_after.png)](https://lh3.googleusercontent.com/-Fz8xHE_bUKg/Wtexi3V7spI/AAAAAAAAEGM/b25LdhMcMPgZZHYhNT-byOr3LChwOvB1gCLcBGAs/s1600/server_pip_package_after.png)

Can anyone explain why state: absent isn’t working as expected?

Thanks,

Guy

---

<div class="post-metadata">

**Author:** ![Guy\_Knights](https://avatars.discourse-cdn.com/v4/letter/g/db5fbb/32.png) [@Guy\_Knights](https://forum.ansible.com/u/Guy_Knights)\
**Post date:** [April 18, 2018, 9:09pm UTC](https://forum.ansible.com/t/pip-module-does-nothing-when-state-absent/27317/2 "2018-04-18T21:09:07Z")

</div>

Right after I posted this I tried uninstalling ndg-httpsclient manually (should’ve tried that first I guess) and I got this error:

Not uninstalling ndg-httpsclient at /usr/lib/python2.7/dist-packages, owned by OS

This was while logged in as root too. Anyway, I ended up having to manually remove the package files in /usr/lib/python2.7/dist-packages which finally worked.

Just noting this here in case it’s useful info.

Thanks,  
Guy

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [April 19, 2018, 5:59am UTC](https://forum.ansible.com/t/pip-module-does-nothing-when-state-absent/27317/3 "2018-04-19T05:59:23Z")

</div>

pip wont uninstall packages installed by the OS package system.  
Bassed on the path I'm guessing you are using Debian or a Debian based distro, to uninstall you need to use the apt module, the package name is python-ndg-httpsclient.
