<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Sean&#039;s Blog &#187; Python</title>
	<atom:link href="http://seanbehan.com/category/python/feed/" rel="self" type="application/rss+xml" />
	<link>http://seanbehan.com</link>
	<description>Web Programming, Ruby on Rails, Wordpress, PHP from Burlington, Vermont</description>
	<lastBuildDate>Wed, 18 Jan 2012 21:44:54 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Installing MatPlotLib on OS X for Python Version 2.6.1 with PIP and VirtualEnv</title>
		<link>http://seanbehan.com/mac-os-x/installing-matplotlib-on-os-x-for-python-version-2-6-1/</link>
		<comments>http://seanbehan.com/mac-os-x/installing-matplotlib-on-os-x-for-python-version-2-6-1/#comments</comments>
		<pubDate>Sat, 23 Apr 2011 21:56:03 +0000</pubDate>
		<dc:creator>bseanvt</dc:creator>
				<category><![CDATA[environment]]></category>
		<category><![CDATA[mac os x]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[matplotlib]]></category>
		<category><![CDATA[package management]]></category>
		<category><![CDATA[pip]]></category>
		<category><![CDATA[virtualenv]]></category>

		<guid isPermaLink="false">http://seanbehan.com/?p=1285</guid>
		<description><![CDATA[If you thought you had installed matplotlib only to find this File "/Library/Python/2.6/site-packages/matplotlib-0.91.1-py2.6-macosx-10.6-universal.egg/matplotlib/numerix/__init__.py", line 166, in __import__('ma', g, l) File "/Library/Python/2.6/site-packages/matplotlib-0.91.1-py2.6-macosx-10.6-universal.egg/matplotlib/numerix/ma/__init__.py", line 16, in from numpy.core.ma import * ImportError: No module named ma It is because the package being installed is version 0.91 and you need at least version 1.0 . If it&#8217;s already installed [...]]]></description>
			<content:encoded><![CDATA[<div style="height:33px;" class="really_simple_share robots-nocontent snap_nopreview"><div class="really_simple_share_facebook_like" style="width:px;">
				<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fseanbehan.com%2Fmac-os-x%2Finstalling-matplotlib-on-os-x-for-python-version-2-6-1%2F&amp;layout=button_count&amp;show_faces=false&amp;width=&amp;action=like&amp;colorscheme=light&amp;send=false&amp;height=27" 
						scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:px; height:27px;" allowTransparency="true"></iframe>
				</div><div class="really_simple_share_twitter" style="width:px;">
					<a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" 
						data-text="Installing MatPlotLib on OS X for Python Version 2.6.1 with PIP and VirtualEnv" data-url="http://seanbehan.com/mac-os-x/installing-matplotlib-on-os-x-for-python-version-2-6-1/" 
						data-via="" ></a> 
				</div></div>
		<div style="clear:both;"></div><p>If you thought you had installed matplotlib only to find this<br />
<code><br />
File "/Library/Python/2.6/site-packages/matplotlib-0.91.1-py2.6-macosx-10.6-universal.egg/matplotlib/numerix/__init__.py", line 166, in <module><br />
    __import__('ma', g, l)<br />
  File "/Library/Python/2.6/site-packages/matplotlib-0.91.1-py2.6-macosx-10.6-universal.egg/matplotlib/numerix/ma/__init__.py", line 16, in <module><br />
    from numpy.core.ma import *<br />
ImportError: No module named ma<br />
</code><br />
It is because the package being installed is version 0.91 and you need at least version 1.0 .</p>
<p>If it&#8217;s already installed pass pip the upgrade flag and specify the package location with the &#8220;-f&#8221; flag<br />
<code><br />
pip install --upgrade -f http://downloads.sourceforge.net/project/matplotlib/matplotlib/matplotlib-1.0/matplotlib-1.0.0.tar.gz matplotlib<br />
</code></p>
<p>If not installed<br />
<code><br />
pip install -f http://downloads.sourceforge.net/project/matplotlib/matplotlib/matplotlib-1.0/matplotlib-1.0.0.tar.gz matplotlib<br />
</code></p>
<p>Resources: </p>
<p>http://stackoverflow.com/questions/3555551/why-does-pip-install-matplotlib-version-0-91-1-when-pypi-shows-version-1-0-0</p>
]]></content:encoded>
			<wfw:commentRss>http://seanbehan.com/mac-os-x/installing-matplotlib-on-os-x-for-python-version-2-6-1/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Mod_Python and Web.py on Ubuntu</title>
		<link>http://seanbehan.com/python/mod_python-and-web-py-on-ubuntu/</link>
		<comments>http://seanbehan.com/python/mod_python-and-web-py-on-ubuntu/#comments</comments>
		<pubDate>Wed, 09 Dec 2009 16:17:16 +0000</pubDate>
		<dc:creator>bseanvt</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[.htacess]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[framework]]></category>
		<category><![CDATA[modpython_gateway]]></category>
		<category><![CDATA[mod_python]]></category>
		<category><![CDATA[mod_rewrite]]></category>
		<category><![CDATA[web.py]]></category>

		<guid isPermaLink="false">http://seanbehan.com/?p=664</guid>
		<description><![CDATA[Download First install mod_python for Apache and then restart/reload the server. apt-get install libapache2-mod-python /etc/init.d/apache2 force-reload apache2ctl restart Next grab the web.py framework from webpy.org. You can grab the tar or use easy_install depending on your setup. wget http://webpy.org/static/web.py-0.33.tar.gz tar xzvf web.py.tar.gz cd web sudo python setup.py install # or if you use easy_install easy_install [...]]]></description>
			<content:encoded><![CDATA[<div style="height:33px;" class="really_simple_share robots-nocontent snap_nopreview"><div class="really_simple_share_facebook_like" style="width:px;">
				<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fseanbehan.com%2Fpython%2Fmod_python-and-web-py-on-ubuntu%2F&amp;layout=button_count&amp;show_faces=false&amp;width=&amp;action=like&amp;colorscheme=light&amp;send=false&amp;height=27" 
						scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:px; height:27px;" allowTransparency="true"></iframe>
				</div><div class="really_simple_share_twitter" style="width:px;">
					<a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" 
						data-text="Mod_Python and Web.py on Ubuntu" data-url="http://seanbehan.com/python/mod_python-and-web-py-on-ubuntu/" 
						data-via="" ></a> 
				</div></div>
		<div style="clear:both;"></div><h3>Download</h3>
<p>First install mod_python for Apache and then restart/reload the server.</p>
<pre class="wp-code-highlight prettyprint">
apt-get install libapache2-mod-python
/etc/init.d/apache2 force-reload
apache2ctl restart
</pre>
<p>Next grab the web.py framework from webpy.org. You can grab the tar or use easy_install depending on your setup.</p>
<pre class="wp-code-highlight prettyprint">
wget http://webpy.org/static/web.py-0.33.tar.gz
tar xzvf web.py.tar.gz
cd web
sudo python setup.py install
# or if you use easy_install
easy_install web.py
</pre>
<p>Download this file <a href="http://www.aminus.net/browser/modpython_gateway.py?rev=106&#038;format=raw">http://www.aminus.net/browser/modpython_gateway.py?rev=106&#038;format=raw</a> This python package can (with this version) go anywhere in your python path &#8220;sys.path&#8221;. However, I placed it in the wsgiref directory. I&#8217;m running python2.6 so I did the following</p>
<pre class="wp-code-highlight prettyprint">
# after downloading
mv modpython_gateway.py /usr/lib/python2.6/wsgiref/modpython_gateway.py
</pre>
<p>It&#8217;s important to remember that in the VirtualHost file you create the PythonHandler directive will need to reference this module. If you place it outside of the wsgiref directory remember to change the directive as well.</p>
<h3>The VirtualHost</h3>
<p>Now we need to create a VirtualHost for our application. You can run web.py apps without apache and this is good for development mode. To do this the command is</p>
<pre class="wp-code-highlight prettyprint">
python pcode.py 4567
</pre>
<p>where the pcode.py is your web.py application filename and the 4567 is the port number you want to start the server on. I think it defaults to 8080. If you&#8217;re running apache or another web server port 80 will be in use. This is where mod_python (or cgi or fastcgi) come into play.</p>
<pre class="wp-code-highlight prettyprint">
&amp;lt;VirtualHost *&amp;gt;
  ServerName py.seanbehan.com
  DocumentRoot /var/www/python/myapp

   #Aliases can trip you up! Pay attention here
   Alias /myapp /var/www/python/myapp
   &amp;lt;Directory /var/www/python/myapp&amp;gt;
      &amp;lt;IfModule python_module&amp;gt;
        PythonPath &quot;sys.path +['/var/www/python/myapp']&quot;
        AddHandler python-program .py
        # modpython_gateway is a file you'll need to download and place in wsgiref
        PythonHandler wsgiref.modpython_gateway::handler
        # This is your python program
        PythonOption wsgi.application pcode::main
        PythonOption SCRIPT_NAME /myapp
        PythonDebug on
      &amp;lt;/IfModule&amp;gt;
    &amp;lt;/Directory&amp;gt;
&amp;lt;/VirtualHost&amp;gt;
</pre>
<h3>Web.py Application</h3>
<p>Web.py applications can be very simple. Everything can be placed in one file. In this example I created a file &#8220;pcode.py&#8221; and saved it to &#8220;/var/www/python/myapp/pcode.py&#8221;. The contents look like this</p>
<pre class="wp-code-highlight prettyprint">
import web #this is the web.py frameword
web.webapi.internalerror = web.debugerror #lets capture errors for debugging

# map paths to classes
urls = (
    &quot;/&quot;, &quot;hello&quot;
)

# this is the main from the PythonOption wsgi.application pcode::main from our VirtualHost
main = web.application(urls, globals()).wsgifunc()

class hello:
    def GET(self):
        #  web.header... otherwise you'll be prompted to save the file rather than view it in the browser
        web.header('Content-type','text/html')
        yield &quot;Finally got web.py to work!&quot;

if __name__ == &quot;__main__&quot;:
    main.run()
</pre>
<p>Save the file, reload apache and visit the location on the web (In my case py.seanbehan.com/pcode.py/). Remember to include that last &#8220;/&#8221; after the pcode.py. You might get a  &#8220;not found&#8221; message from web.py otherwise.</p>
<h3>Pretty URLs</h3>
<p>You can get pretty urls like &#8220;py.seanbehan.com/hello/world&#8221; if you use the mod_rewrite apache module.</p>
<pre class="wp-code-highlight prettyprint">
a2enmod rewrite
</pre>
<p>You can either set up the rewrite rules in your VirtualHost or in a .htaccess file. I&#8217;ll do the .htaccess so I don&#8217;t have to reload the server for the changes to take effect.</p>
<p>In the same directory as your pcode.py file create a file &#8220;.htaccess&#8221; and in it place this code</p>
<pre class="wp-code-highlight prettyprint">
&amp;lt;IfModule mod_rewrite.c&amp;gt;
  RewriteEngine on
  RewriteBase /
  RewriteCond %{REQUEST_URI} !^/icons
  RewriteCond %{REQUEST_URI} !^/favicon.ico$
  RewriteCond %{REQUEST_URI} !^(/.*)+code.py/
  RewriteRule ^(.*)$ pcode.py/$1 [PT]
&amp;lt;/IfModule&amp;gt;
</pre>
<h3>Troubleshooting</h3>
<p>I ran into some trouble with the Alias in the VirtualHost file. It looks like this</p>
<pre class="wp-code-highlight prettyprint">
Alias /myapp /var/www/python/myapp
</pre>
<p>This will map incoming urls to the full path on the filesystem so that your python program will run properly. I kept getting the not found error message from web.py without it. There might be a better way to set this up but this is how I got it to work.</p>
<p>Here are some additional resources I found helpful<br />
<a href="http://wiki.slicehost.com/doku.php?id=install_mod_wsgi_on_ubuntu_gutsy">http://wiki.slicehost.com/doku.php?id=install_mod_wsgi_on_ubuntu_gutsy<br />
</a><br />
<a href="http://webpy.org/install">http://webpy.org/install</a><br />
<a href="http://dready.org/blog/2009/01/29/webpy-with-mod_python-on-apache/">http://dready.org/blog/2009/01/29/webpy-with-mod_python-on-apache/</a><br />
<a href="http://www.devisland.net/help/webpy.shtml">http://www.devisland.net/help/webpy.shtml</a></p>
]]></content:encoded>
			<wfw:commentRss>http://seanbehan.com/python/mod_python-and-web-py-on-ubuntu/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>SHA1 or MD5 Hashing in Python</title>
		<link>http://seanbehan.com/python/sha1-or-md5-hashing-in-python/</link>
		<comments>http://seanbehan.com/python/sha1-or-md5-hashing-in-python/#comments</comments>
		<pubDate>Sat, 10 Oct 2009 20:37:28 +0000</pubDate>
		<dc:creator>bseanvt</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[hashlib]]></category>
		<category><![CDATA[md5]]></category>
		<category><![CDATA[sha1]]></category>

		<guid isPermaLink="false">http://seanbehan.com/?p=578</guid>
		<description><![CDATA[import hashlib print hashlib.sha1(&#34;My wonderful string&#34;).hexdigest() print hashlib.md5(&#34;My other wonderful string&#34;).hexdigest()]]></description>
			<content:encoded><![CDATA[<div style="height:33px;" class="really_simple_share robots-nocontent snap_nopreview"><div class="really_simple_share_facebook_like" style="width:px;">
				<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fseanbehan.com%2Fpython%2Fsha1-or-md5-hashing-in-python%2F&amp;layout=button_count&amp;show_faces=false&amp;width=&amp;action=like&amp;colorscheme=light&amp;send=false&amp;height=27" 
						scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:px; height:27px;" allowTransparency="true"></iframe>
				</div><div class="really_simple_share_twitter" style="width:px;">
					<a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" 
						data-text="SHA1 or MD5 Hashing in Python" data-url="http://seanbehan.com/python/sha1-or-md5-hashing-in-python/" 
						data-via="" ></a> 
				</div></div>
		<div style="clear:both;"></div><pre class="wp-code-highlight prettyprint">
import hashlib
print hashlib.sha1(&quot;My wonderful string&quot;).hexdigest()
print hashlib.md5(&quot;My other wonderful string&quot;).hexdigest()
</pre>
]]></content:encoded>
			<wfw:commentRss>http://seanbehan.com/python/sha1-or-md5-hashing-in-python/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Dynamic Attributes in Python Model Class</title>
		<link>http://seanbehan.com/python/dynamic-attributes-in-python-model-class/</link>
		<comments>http://seanbehan.com/python/dynamic-attributes-in-python-model-class/#comments</comments>
		<pubDate>Sat, 10 Oct 2009 20:34:12 +0000</pubDate>
		<dc:creator>bseanvt</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[dict]]></category>
		<category><![CDATA[dynamc]]></category>

		<guid isPermaLink="false">http://seanbehan.com/?p=576</guid>
		<description><![CDATA[class Bar(): def __init__(self, **args): for key in args: self.__dict__[key] = args[key] b = Bar(fullname=&#34;Monty Python&#34;, email=&#34;me@monthpython.org&#34;) b.fullname #=&#62; Monty Python b.email #=&#62;me@montypython.org]]></description>
			<content:encoded><![CDATA[<div style="height:33px;" class="really_simple_share robots-nocontent snap_nopreview"><div class="really_simple_share_facebook_like" style="width:px;">
				<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fseanbehan.com%2Fpython%2Fdynamic-attributes-in-python-model-class%2F&amp;layout=button_count&amp;show_faces=false&amp;width=&amp;action=like&amp;colorscheme=light&amp;send=false&amp;height=27" 
						scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:px; height:27px;" allowTransparency="true"></iframe>
				</div><div class="really_simple_share_twitter" style="width:px;">
					<a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" 
						data-text="Dynamic Attributes in Python Model Class" data-url="http://seanbehan.com/python/dynamic-attributes-in-python-model-class/" 
						data-via="" ></a> 
				</div></div>
		<div style="clear:both;"></div><pre class="wp-code-highlight prettyprint">
class Bar():
    def __init__(self, **args):
        for key in args:
            self.__dict__[key] = args[key]

b = Bar(fullname=&quot;Monty Python&quot;, email=&quot;me@monthpython.org&quot;)
b.fullname #=&gt; Monty Python
b.email #=&gt;me@montypython.org
</pre>
]]></content:encoded>
			<wfw:commentRss>http://seanbehan.com/python/dynamic-attributes-in-python-model-class/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Python Zlib Compress DeCompress</title>
		<link>http://seanbehan.com/python/python-zlib-compress-decompress/</link>
		<comments>http://seanbehan.com/python/python-zlib-compress-decompress/#comments</comments>
		<pubDate>Fri, 09 Oct 2009 18:34:21 +0000</pubDate>
		<dc:creator>bseanvt</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[compression]]></category>
		<category><![CDATA[import]]></category>
		<category><![CDATA[zlib]]></category>

		<guid isPermaLink="false">http://seanbehan.com/?p=574</guid>
		<description><![CDATA[import zlib regular_string = 'this is my string' compressed_string = zlib.compress(regular_string) decompressed_string = zlib.decompress(compressed_string) print compressed_string print decompressed_string]]></description>
			<content:encoded><![CDATA[<div style="height:33px;" class="really_simple_share robots-nocontent snap_nopreview"><div class="really_simple_share_facebook_like" style="width:px;">
				<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fseanbehan.com%2Fpython%2Fpython-zlib-compress-decompress%2F&amp;layout=button_count&amp;show_faces=false&amp;width=&amp;action=like&amp;colorscheme=light&amp;send=false&amp;height=27" 
						scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:px; height:27px;" allowTransparency="true"></iframe>
				</div><div class="really_simple_share_twitter" style="width:px;">
					<a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" 
						data-text="Python Zlib Compress DeCompress" data-url="http://seanbehan.com/python/python-zlib-compress-decompress/" 
						data-via="" ></a> 
				</div></div>
		<div style="clear:both;"></div><pre class="wp-code-highlight prettyprint">
import zlib
regular_string = 'this is my string'
compressed_string = zlib.compress(regular_string)
decompressed_string = zlib.decompress(compressed_string)

print compressed_string
print decompressed_string
</pre>
]]></content:encoded>
			<wfw:commentRss>http://seanbehan.com/python/python-zlib-compress-decompress/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Pickle Python Objects</title>
		<link>http://seanbehan.com/python/pickle-python-objects/</link>
		<comments>http://seanbehan.com/python/pickle-python-objects/#comments</comments>
		<pubDate>Fri, 09 Oct 2009 17:48:02 +0000</pubDate>
		<dc:creator>bseanvt</dc:creator>
				<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://seanbehan.com/?p=572</guid>
		<description><![CDATA[import pickle entity = { &#34;user_id&#34;: &#34;1&#34;, &#34;title&#34;: &#34;Natural Dog Training&#34;, &#34;link&#34;: &#34;http://naturaldogtraining.com&#34;, } pickled_entity = pickle.dumps(entity) unpickled_entity = pickle.loads(pickled_entity)]]></description>
			<content:encoded><![CDATA[<div style="height:33px;" class="really_simple_share robots-nocontent snap_nopreview"><div class="really_simple_share_facebook_like" style="width:px;">
				<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fseanbehan.com%2Fpython%2Fpickle-python-objects%2F&amp;layout=button_count&amp;show_faces=false&amp;width=&amp;action=like&amp;colorscheme=light&amp;send=false&amp;height=27" 
						scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:px; height:27px;" allowTransparency="true"></iframe>
				</div><div class="really_simple_share_twitter" style="width:px;">
					<a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" 
						data-text="Pickle Python Objects" data-url="http://seanbehan.com/python/pickle-python-objects/" 
						data-via="" ></a> 
				</div></div>
		<div style="clear:both;"></div><pre class="wp-code-highlight prettyprint">
import pickle
entity = {
	&quot;user_id&quot;: &quot;1&quot;,
	&quot;title&quot;: &quot;Natural Dog Training&quot;,
	&quot;link&quot;: &quot;http://naturaldogtraining.com&quot;,
}
pickled_entity = pickle.dumps(entity)
unpickled_entity = pickle.loads(pickled_entity)
</pre>
]]></content:encoded>
			<wfw:commentRss>http://seanbehan.com/python/pickle-python-objects/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Install MySQLdb for Python on Mac OS X</title>
		<link>http://seanbehan.com/python/install-mysqldb-for-python-on-mac-os-x/</link>
		<comments>http://seanbehan.com/python/install-mysqldb-for-python-on-mac-os-x/#comments</comments>
		<pubDate>Thu, 17 Sep 2009 04:17:37 +0000</pubDate>
		<dc:creator>bseanvt</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[tornado]]></category>

		<guid isPermaLink="false">http://seanbehan.com/?p=533</guid>
		<description><![CDATA[I don&#8217;t do much python development. I really like the language and there are a lot of great software projects out there for it. Tornado, for example, is a fast non-blocking web server in python, just open sourced by Facebook that is the engine behind FriendFeed.com. I downloaded the source, available at, http://tornadoweb.org, and started [...]]]></description>
			<content:encoded><![CDATA[<div style="height:33px;" class="really_simple_share robots-nocontent snap_nopreview"><div class="really_simple_share_facebook_like" style="width:px;">
				<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fseanbehan.com%2Fpython%2Finstall-mysqldb-for-python-on-mac-os-x%2F&amp;layout=button_count&amp;show_faces=false&amp;width=&amp;action=like&amp;colorscheme=light&amp;send=false&amp;height=27" 
						scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:px; height:27px;" allowTransparency="true"></iframe>
				</div><div class="really_simple_share_twitter" style="width:px;">
					<a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" 
						data-text="Install MySQLdb for Python on Mac OS X" data-url="http://seanbehan.com/python/install-mysqldb-for-python-on-mac-os-x/" 
						data-via="" ></a> 
				</div></div>
		<div style="clear:both;"></div><p>I don&#8217;t do much python development. I really like the language and there are a lot of great software projects out there for it. Tornado, for example, is a fast non-blocking web server in python, just open sourced by Facebook that is the engine behind FriendFeed.com.</p>
<p>I downloaded the source, available at, http://tornadoweb.org, and started playing around. It comes with a database wrapper for mysql. Using &#8220;easy_install&#8221;, I suppose the python equivalent to gems, it goes something like this&#8230;</p>
<pre class="wp-code-highlight prettyprint">
sudo easy_install MySQLdb-python
</pre>
<p>Nope :( at least not on OS X. Time to do it the hard way. Luckily not too hard. It just can&#8217;t find the right path to mysql_config. Sound familiar? http://seanbehan.com/databases/install-do_mysql-ruby-gem-on-mac-os-x/</p>
<p>Anyway, here are the commands that worked for me&#8230;</p>
<pre class="wp-code-highlight prettyprint">
wget http://dl.sourceforge.net/sourceforge/mysql-python/MySQL-python-1.2.3c1.tar.gz
tar xzvf MySQL-python-1.2.3c1.tar.gz
cd MySQL-python-1.2.3c1
</pre>
<p> In the setup_posix.py file change</p>
<pre class="wp-code-highlight prettyprint">
mysql_config.path = &quot;mysql_config&quot;
</pre>
<p>to</p>
<pre class="wp-code-highlight prettyprint">
mysql_config.path = &quot;/opt/local/lib/mysql5/bin/mysql_config&quot;
</pre>
<p>Next install it with these commands</p>
<pre class="wp-code-highlight prettyprint">
 python setup.py clean
 python setup.py build
 sudo python setup.py install
</pre>
<p>That should do it.</p>
]]></content:encoded>
			<wfw:commentRss>http://seanbehan.com/python/install-mysqldb-for-python-on-mac-os-x/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

