title: Unable to install MySQL-python
body: <p>Okay I recently upgraded from Ubuntu 10.04 to 12.04</p>
  
  <p>Only to be faced by a lot of problems. I am a newbie at this so you might have to tell me in a little more detail or step-by-step</p>
  
  <p>I had a django project that was working perfectly but now it gives me this error :</p>
  
  <pre><code>  File "/usr/local/lib/python2.7/site-packages/django/db/backends/mysql/base.py", line 16, in &lt;module&gt;
      raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e) django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: libmysqlclient_r.so.16: cannot open shared object file: No such file or directory
  </code></pre>
  
  <p>or in python :</p>
  
  <pre><code>&gt;&gt;&gt; import MySQLdb
  Traceback (most recent call last):
    File "&lt;stdin&gt;", line 1, in &lt;module&gt;
    File "build/bdist.linux-i686/egg/MySQLdb/__init__.py", line 19, in &lt;module&gt;
    File "build/bdist.linux-i686/egg/_mysql.py", line 7, in &lt;module&gt;
    File "build/bdist.linux-i686/egg/_mysql.py", line 6, in __bootstrap__
  ImportError: libmysqlclient_r.so.16: cannot open shared object file: No such file or directory
  </code></pre>
  
  <p>Anyways I thought there was some problem with my MySQL-python so I tried re-installing it.</p>
  
  <pre><code>sudo pip install mysql-python
  </code></pre>
  
  <p>gives :</p>
  
  <pre><code>Downloading/unpacking mysql-python
    Running setup.py egg_info for package mysql-python
      The required version of distribute (&gt;=0.6.28) is not available,
      and can't be installed while this script is running. Please
      install a more recent version first, using
      'easy_install -U distribute'.
  
      (Currently using distribute 0.6.24dev-r0 (/usr/lib/python2.7/dist-packages))
      Complete output from command python setup.py egg_info:
      The required version of distribute (&gt;=0.6.28) is not available,
  
  and can't be installed while this script is running. Please
  
  install a more recent version first, using
  
  'easy_install -U distribute'.
  
  
  
  (Currently using distribute 0.6.24dev-r0 (/usr/lib/python2.7/dist-packages))
  
  ----------------------------------------
  Command python setup.py egg_info failed with error code 2 in /tmp/pip-build/mysql-python
  Storing complete log in /home/nabeel/.pip/pip.log
  </code></pre>
  
  <p>If I do :</p>
  
  <pre><code>sudo easy_install -U distribute
  </code></pre>
  
  <p>It gives this error :</p>
  
  <pre><code>Searching for distribute
  Reading http://pypi.python.org/simple/distribute/
  Reading http://packages.python.org/distribute
  Best match: distribute 0.6.29
  Downloading http://pypi.python.org/packages/source/d/distribute/distribute-0.6.29.tar.gz#md5=1aad767bfca8bebaccafee25f85696cf
  Processing distribute-0.6.29.tar.gz
  Running distribute-0.6.29/setup.py -q bdist_egg --dist-dir /tmp/easy_install-K8ZuMX/distribute-0.6.29/egg-dist-tmp-Fj0gj_
  Before install bootstrap.
  Scanning installed packages
  Setuptools installation detected at /usr/local/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg
  Egg installation
  Patching...
  Renaming /usr/local/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg to /usr/local/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg.OLD.1350776909.4
  Patching complete.
  Relaunching...
  Traceback (most recent call last):
    File "/usr/local/bin/easy_install", line 9, in &lt;module&gt;
      load_entry_point('distribute==0.6.8', 'console_scripts', 'easy_install')()
    File "/usr/local/lib/python2.7/site-packages/distribute-0.6.8-py2.7.egg/setuptools/command/easy_install.py", line 1708, in main
      with_ei_usage(lambda:
    File "/usr/local/lib/python2.7/site-packages/distribute-0.6.8-py2.7.egg/setuptools/command/easy_install.py", line 1696, in with_ei_usage
      return f()
    File "/usr/local/lib/python2.7/site-packages/distribute-0.6.8-py2.7.egg/setuptools/command/easy_install.py", line 1712, in &lt;lambda&gt;
      distclass=DistributionWithoutHelpCommands, **kw
    File "/usr/local/lib/python2.7/distutils/core.py", line 152, in setup
      dist.run_commands()
    File "/usr/local/lib/python2.7/distutils/dist.py", line 953, in run_commands
      self.run_command(cmd)
    File "/usr/local/lib/python2.7/distutils/dist.py", line 972, in run_command
      cmd_obj.run()
    File "/usr/local/lib/python2.7/site-packages/distribute-0.6.8-py2.7.egg/setuptools/command/easy_install.py", line 236, in run
      self.easy_install(spec, not self.no_deps)
    File "/usr/local/lib/python2.7/site-packages/distribute-0.6.8-py2.7.egg/setuptools/command/easy_install.py", line 471, in easy_install
      return self.install_item(spec, dist.location, tmpdir, deps)
    File "/usr/local/lib/python2.7/site-packages/distribute-0.6.8-py2.7.egg/setuptools/command/easy_install.py", line 501, in install_item
      dists = self.install_eggs(spec, download, tmpdir)
    File "/usr/local/lib/python2.7/site-packages/distribute-0.6.8-py2.7.egg/setuptools/command/easy_install.py", line 680, in install_eggs
      return self.build_and_install(setup_script, setup_base)
    File "/usr/local/lib/python2.7/site-packages/distribute-0.6.8-py2.7.egg/setuptools/command/easy_install.py", line 957, in build_and_install
      self.run_setup(setup_script, setup_base, args)
    File "/usr/local/lib/python2.7/site-packages/distribute-0.6.8-py2.7.egg/setuptools/command/easy_install.py", line 946, in run_setup
      run_setup(setup_script, args)
    File "/usr/local/lib/python2.7/site-packages/distribute-0.6.8-py2.7.egg/setuptools/sandbox.py", line 29, in run_setup
      lambda: execfile(
    File "/usr/local/lib/python2.7/site-packages/distribute-0.6.8-py2.7.egg/setuptools/sandbox.py", line 70, in run
      return func()
    File "/usr/local/lib/python2.7/site-packages/distribute-0.6.8-py2.7.egg/setuptools/sandbox.py", line 31, in &lt;lambda&gt;
      {'__file__':setup_script, '__name__':'__main__'}
    File "setup.py", line 131, in &lt;module&gt;
    File "/tmp/easy_install-K8ZuMX/distribute-0.6.29/distribute_setup.py", line 368, in _before_install
    File "/tmp/easy_install-K8ZuMX/distribute-0.6.29/distribute_setup.py", line 441, in _fake_setuptools
    File "/tmp/easy_install-K8ZuMX/distribute-0.6.29/distribute_setup.py", line 450, in _relaunch
  NameError: global name '_cmd1' is not defined
  </code></pre>
  
  <p>Again now I have gone to this link :
  <a href="http://pypi.python.org/pypi/setuptools/0.6c11" rel="noreferrer">http://pypi.python.org/pypi/setuptools/0.6c11</a>
  to download and install setuptools..
  I have also installed the latest distribute 0.6.8 from here :
  <a href="http://pypi.python.org/pypi/distribute/0.6.8" rel="noreferrer">http://pypi.python.org/pypi/distribute/0.6.8</a></p>
  
  <p>I have also tried uninstalling the previous versions and installing back but it doesn't seems to work.
  I have got Python 2.7.3 installed</p>
  
  <p>Could someone please explain to me what is going on... How I can install Mysqldb...</p>
  
  <p>I have also ran these commands on shell :</p>
  
  <pre><code>sudo apt-get install mysql-server mysql-client python-mysqldb libmysqlclient-dev python-dev
  </code></pre>
  
  <p>But it didn't help ...</p>
  
  <p><strong>UPDATE I JUST DID THIS AND GOT THIS ERROR :</strong></p>
  
  <pre><code>nabeel@nabeel-pc:~$ pip uninstall setuptools
  Uninstalling distribute:
    /usr/bin/easy_install
    /usr/bin/easy_install-2.7
    /usr/lib/python2.7/dist-packages/distribute-0.6.24dev_r0.egg-info
    /usr/lib/python2.7/dist-packages/easy_install.pyc
    /usr/lib/python2.7/dist-packages/pkg_resources.pyc
    /usr/lib/python2.7/dist-packages/setuptools
    /usr/lib/python2.7/dist-packages/site.pyc
    /usr/share/pyshared/easy_install.py
    /usr/share/pyshared/pkg_resources.py
    /usr/share/pyshared/site.py
  Proceed (y/n)? y
    Successfully uninstalled distribute
  nabeel@nabeel-pc:~$ sudo easy_install -U distribute
  Searching for distribute
  Reading http://pypi.python.org/simple/distribute/
  Reading http://packages.python.org/distribute
  Best match: distribute 0.6.29
  Downloading http://pypi.python.org/packages/source/d/distribute/distribute-0.6.29.tar.gz#md5=1aad767bfca8bebaccafee25f85696cf
  Processing distribute-0.6.29.tar.gz
  Running distribute-0.6.29/setup.py -q bdist_egg --dist-dir /tmp/easy_install-Xcer8d/distribute-0.6.29/egg-dist-tmp-K0E7gP
  Before install bootstrap.
  Scanning installed packages
  Setuptools installation detected at /usr/local/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg
  Egg installation
  Already patched.
  After install bootstrap.
  Creating /usr/local/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg-info
  Creating /usr/local/lib/python2.7/site-packages/setuptools.pth
  Removing distribute 0.6.8 from easy-install.pth file
  Adding distribute 0.6.29 to easy-install.pth file
  Installing easy_install script to /usr/local/bin
  Installing easy_install-2.7 script to /usr/local/bin
  
  Installed /usr/local/lib/python2.7/site-packages/distribute-0.6.29-py2.7.egg
  Processing dependencies for distribute
  Finished processing dependencies for distribute
  nabeel@nabeel-pc:~$ sudo pip install mysql-python
  Traceback (most recent call last):
    File "/usr/local/bin/pip", line 5, in &lt;module&gt;
      from pkg_resources import load_entry_point
  ImportError: No module named pkg_resources
  </code></pre>
  
  <p><strong>UPDATE 2 :</strong>
  I have managed to install virtualenv
  now in the environment I have also managed to install MySQLdb.
  Here's theh error I get while running my server :</p>
  
  <pre><code>sudo python manage.py syncdb
  </code></pre>
  
  <p>I get this error:</p>
  
  <pre><code>  File "/usr/local/lib/python2.7/site-packages/django/db/backends/mysql/base.py", line 16, in &lt;module&gt;
      raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e)
  django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: libmysqlclient_r.so.16: cannot open shared object file: No such file or directory
  
  
  (myenv)nabeel@nabeel-pc:~/workspace/gteam/metrics$ python
      Python 2.7.3 (default, Oct  6 2012, 21:57:36) 
      [GCC 4.4.3] on linux2
      Type "help", "copyright", "credits" or "license" for more information.
      &gt;&gt;&gt; import MySQLdb
      &gt;&gt;&gt; exit()
  </code></pre>