Sunday, November 29, 2015

MAMP Success

mamp_pro_demo
control panel:  manage MySQL + Apache


MAMP is the community / free version of MAMP Pro, a product out of Germany.

I'm having a pleasant experience getting it to work with the latest Anaconda, meaning I'm able to get not only PHP working against its MySQL database, but also Python 3.5 as a mod_wsgi application under Apache.

Not only that, my Anaconda Spyder IDE is happy to let me connect to the same MySQL database interactively, through the REPL, after using conda install to grab mysql.connector -- pretty painless.

conda_connecting
talking to MAMP's MySQL on localhost:8889 (other ports possible)

First I scared myself with some reading on StackOverFlow, then these excellent two blog posts, at Racing Tadpole by Arthur Street, and this WSGI tutorial from where I grabbed some code.

In practice however, much less was involved in getting all this to work.  I've learned to study log files more and the Apache error log told me what I needed to know:  Target WSGI script '/Applications/MAMP/htdocs/pyhello.py' does not contain WSGI application 'application'.  Thank you.


need_wsgi_app
MAMP shows Apache log files

conda_sql
using conda install to get mysql-connector-python

OK, now that we're through the headlines, let me given some more background:  you might want to use MAMP to mirror whatever LAMP stack you're developing, perhaps still learning about LAMP in general.

I'm using MAMP to finally tackle PHP which the Quakers are using at NPYM.org.  As their Technology Clerk, I want to bring my skill set more into alignment with that org's needs.

I'm reading through a book in Safari On-line, Head First PHP & MySQL by Beighley and Morrison, where we're trying to rescue this guy's dog Fang, which was abducted by aliens. Thanks to mysql.connector, I'm reading the very same database of alien abuction reports from Python as well.

php_book

Anaconda from Continuum Analytics is the hot Science Oriented Distro (SOD) for those wanting a cutting edge slice into scientific Python.

Am I saying it's either / or, as if web development were anti-scientific?  No of course not.  I'm just exulting at the inter-operability of these two well-supported tools.  Note that I'm using #!/Users/kurner/anaconda/bin/python as my shebang line of the wsgi scripts.

wsgi_anaconda
remember to tell Apache which Python we're using i.e. Anaconda's 3.5

Yes, I'm on a Mac.  I'm not sure how all this comes together in Ubuntu, I hope just as seamlessly, and of course on Windows.