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 python.org
3. Edit http.conf in your apache. Go to you XAMPP manager, Select Apache then click the Configure button:
Then click the Open Conf File, and the httpd.conf file will be open
Find: AddHandler cgi-script .cgi .pl .asp and add .py and save
4. Instal PIP in your machine
– download get-pip.py
– Then type this in your terminal:
sudo python get-pip.py
5. Then lastly install PyMYSQL
type this command: pip install PyMysql
6. Then restart your apache and Mysql
7. And done we can now test our code. Create a python file. eg. index.py and type this sample code:
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 index.py
8. and done you can now run your code:
– it means my code is correct, no error and I connected to the database.