Setting up Python and PyMYSQL on your MAC

Just to share this with you. I just successfully setup a Python and PyMYSQL on my machine.   This means I can now start playing and start Python websites. Yey!

By the way, I just  completed my “An Introduction to Interactive Programming in Python” course and that’s why I’m now practicing the Python Web Development with Database. By the way, check out my very cool coursera certificate from Rice University.

Okay, Back to the show. Everything are free to download and just follow this very easy steps:

1. Download and Install XAMPP – make sure MySQL and Apache is running

2. Python – download and install it at

3. Edit http.conf in your apache. Go to you XAMPP manager, Select Apache then click the Configure button:

Screen Shot 2014-12-03 at 11.43.38 pm


Then click the Open Conf File, and the httpd.conf file will be open

Screen Shot 2014-12-03 at 11.44.38 pm


Find: AddHandler cgi-script .cgi .pl .asp and add .py and save

Screen Shot 2014-12-03 at 11.46.22 pm



4. Instal PIP in your machine

– download

– Then type this in your terminal:

sudo python

5. Then lastly install PyMYSQL

type this command: pip install PyMysql

Screen Shot 2014-12-03 at 11.53.07 pm


6. Then restart your apache and Mysql

7. And done we can now test our code. Create a python file. eg. and type this sample code:

Screen Shot 2014-12-03 at 11.55.08 pm

Line 1: Is a must: #!/usr/bin/python -> this is for mac only, different for windows

7. Make the file rewritable by entering this command: sudo chmod 755

Screen Shot 2014-12-03 at 11.57.37 pm


8. and done you can now run your code:

Screen Shot 2014-12-03 at 11.58.23 pm

– it means my code is correct, no error and I connected to the database.



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Website Powered by

Up ↑

%d bloggers like this: