# the python mysqldb module is required

**URL:** <https://forum.ansible.com/t/the-python-mysqldb-module-is-required/14251>\
**Category:** Ansible Project\
**Created:** [January 2, 2014, 1:56pm UTC](https://forum.ansible.com/t/the-python-mysqldb-module-is-required/14251 "2014-01-02T13:56:49Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![nORKy](https://avatars.discourse-cdn.com/v4/letter/n/ea666f/32.png) [@nORKy](https://forum.ansible.com/u/nORKy)\
**Post date:** [January 2, 2014, 1:56pm UTC](https://forum.ansible.com/t/the-python-mysqldb-module-is-required/14251/1 "2014-01-02T13:56:49Z")

</div>

Hi,

I have a problem with ansible 1.4.1 and 1.4.3.

When I start my playbook with a MySQL\_db task, it says:

> the python mysqldb module is required

But, in the target host, the module is present :

$ python  
Python 2.7.6 (default, Jan 2 2014, 13:21:14)  
[GCC 4.2.1 20070831 patched [FreeBSD]] on freebsd9  
Type “help”, “copyright”, “credits” or “license” for more information.

> > > import MySQLdb

The target host is a FreeBSD-9.2-RELEASE

What is the problem ? thanks you

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [January 2, 2014, 9:49pm UTC](https://forum.ansible.com/t/the-python-mysqldb-module-is-required/14251/2 "2014-01-02T21:49:08Z")

</div>

The problem is that you need to install the python mysqldb module to use the Ansible module.

You can install this using OS packages (preferred) or pip.

---

<div class="post-metadata">

**Author:** ![nORKy](https://avatars.discourse-cdn.com/v4/letter/n/ea666f/32.png) [@nORKy](https://forum.ansible.com/u/nORKy)\
**Post date:** [January 3, 2014, 7:45am UTC](https://forum.ansible.com/t/the-python-mysqldb-module-is-required/14251/3 "2014-01-03T07:45:18Z")

</div>

I installed. Look my import exemple. There is no exception.  
I said ‘target’ host but I installed on the ‘server’ host too.

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [January 3, 2014, 12:57pm UTC](https://forum.ansible.com/t/the-python-mysqldb-module-is-required/14251/4 "2014-01-03T12:57:28Z")

</div>

The module is required where the task is being run, which is likely the remote host.

“There is no exception.”

Yep, this is what I’d expect too! that means we are catching the error and presenting you a human readable warning instead of a traceback.

---

<div class="post-metadata">

**Author:** ![nORKy](https://avatars.discourse-cdn.com/v4/letter/n/ea666f/32.png) [@nORKy](https://forum.ansible.com/u/nORKy)\
**Post date:** [January 3, 2014, 1:19pm UTC](https://forum.ansible.com/t/the-python-mysqldb-module-is-required/14251/5 "2014-01-03T13:19:03Z")

</div>

ok, so the module is installed on my remote host.  
How can I have the traceback ? The module works manually not with ansible.

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [January 3, 2014, 1:30pm UTC](https://forum.ansible.com/t/the-python-mysqldb-module-is-required/14251/6 "2014-01-03T13:30:46Z")

</div>

You don’t want the traceback, proper error handling is better.

Please show the steps you have taken to have the module installed on the remote host, and the snippet of your playbook that uses it.

---

<div class="post-metadata">

**Author:** ![nORKy](https://avatars.discourse-cdn.com/v4/letter/n/ea666f/32.png) [@nORKy](https://forum.ansible.com/u/nORKy)\
**Post date:** [January 7, 2014, 8:14am UTC](https://forum.ansible.com/t/the-python-mysqldb-module-is-required/14251/7 "2014-01-07T08:14:16Z")

</div>

On my freebsd host “pkg install Py27èMySQLdb-1.2.3\_2”

My task :

- name: create db  
mysql\_db:  
name: “{{ item.1 }}”  
login\_host: “myhost”  
login\_password: “mypassword”  
login\_user: “root”  
state: present  
with\_subelements:
- users
- db  
tags:
- db

---

<div class="post-metadata">

**Author:** ![Berend\_de\_Boer](https://avatars.discourse-cdn.com/v4/letter/b/e495f1/32.png) [@Berend\_de\_Boer](https://forum.ansible.com/u/Berend_de_Boer)\
**Post date:** [August 7, 2015, 9:16pm UTC](https://forum.ansible.com/t/the-python-mysqldb-module-is-required/14251/8 "2015-08-07T21:16:57Z")

</div>

For those confused by the formatting in the last email, and finding this through google, here the FreeBSD command:

pkgng: name=databases/py-MySQLdb state=present
