title: Error importing MySQL package for Python
body: <p>I'm trying to import a MySQL module with python, more specifically Flask, though I receive an error. I'm using a virtual environment with my application. Here is the error:</p>
  
  <pre><code>    Traceback (most recent call last):
    File "../myapp/application.py", line 9, in &lt;module&gt;
      from flask.ext.mysql import MySQL
    File "/Users/pavsidhu/Documents/Web-Development/app/env/lib/python2.7/site-packages/flask/exthook.py", line 81, in load_module
      reraise(exc_type, exc_value, tb.tb_next)
    File "/Users/pavsidhu/Documents/Web-Development/app/env/lib/python2.7/site-packages/flaskext/mysql.py", line 3, in &lt;module&gt;
      import MySQLdb
    File "/Users/pavsidhu/Documents/Web-Development/app/env/lib/python2.7/site-packages/MySQLdb/__init__.py", line 19, in &lt;module&gt;
      import _mysql
  ImportError: dlopen(/Users/pavsidhu/Documents/Web-Development/app/env/lib/python2.7/site-packages/_mysql.so, 2): Library not loaded: /Library/Python/2.7/site-packages/_mysql.so
    Referenced from: /Users/pavsidhu/Documents/Web-Development/app/env/lib/python2.7/site-packages/_mysql.so
    Reason: image not found
  </code></pre>
  
  <p>I can see in the error it says <code>Library not loaded: /Library/Python/2.7/site-packages/_mysql.so</code>. As I'm using a virtual environment that path is incorrect. It should be <code>/lib/python2.7/site-packages/_mysql.so</code>.</p>
  
  <p>Is there a way to change this? Thanks.</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>I found there was a terminal command on OSX to change the library location:</p>
  
  <pre><code> sudo install_name_tool -change libmysqlclient.18.dylib /lib/python2.7/site-packages/MySQLdb/
  </code></pre>
  
  <p>though after hitting enter I get this:</p>
  
  <pre><code>Usage: /Library/Developer/CommandLineTools/usr/bin/install_name_tool [-change old new] ... [-rpath old new] ... [-add_rpath new] ... [-delete_rpath old] ... [-id name] input
  </code></pre>
  
  <p>I don't appear to be entering the command wrong, what is the issue?</p>