Tuesday, December 4, 2012

Google App Engine :: Mac OS

Download & Install
URL: https://developers.google.com/appengine/downloads
> Download the Google App Engine SDK
> GoogleAppEngineLauncher-1.7.3.dmg
> Double-click on dmg file to install.

Following tutorials at 
https://developers.google.com/appengine/docs/python/gettingstarted/

Created the folder
$ mkdir /path/to/tutorials/helloworld
$ cd /path/to/tutorials/helloworld
$ touch app.yaml helloworld.py

Contents of helloworld.py
print 'Content-Type: text/plain'
print ''
print 'Hello World'

Contents of app.yaml
application: helloworld
version: 1
runtime: python
api_version: 1

handlers:
- url: /.*
  script: helloworld.py

Start Google App Engine.
File > Add Existing Application > helloworld > open > Run

ERROR:
*** Running dev_appserver with the following flags:
    --admin_console_server= --port=8080
Python command: /usr/bin/python
WARNING  2012-12-04 16:23:33,337 rdbms_mysqldb.py:74] The rdbms API is not available because the MySQLdb library could not be loaded.

Checking Python version
$ which python
/Library/Frameworks/Python.framework/Versions/2.7/bin/python
$ python --version
Python 2.7

Checking for MySQL
$ mysqladmin -u root -p status
Enter password: 
Uptime: 2627  Threads: 1  Questions: 3  Slow queries: 0  Opens: 33  Flush tables: 1  Open tables: 26  Queries per second avg: 0.001

If you have already install Macports
$ sudo port install py26-mysql

Else, Install Macports
url: https://distfiles.macports.org/MacPorts/
download: MacPorts-2.1.2.tar.gz

On terminal
$ tar zxvf MacPorts-2.1.2.tar.gz
$ cd MacPorts-2.1.2
$ ./configure
$ make
$ sudo make install
/opt/local/bin should be added to my $PATH
$ vim ~/.bashrc
export PATH=$PATH:/opt/local/bin
$ source ~/.bashrc
$ sudo port -v selfupdate
$ sudo port search python | grep mysql
$ sudo port install py26-mysql

Using Macports didnot solve my problem.
So I will use the MySQL-python binaries.
URL: http://sourceforge.net/projects/mysql-python/
Download: MySQL-python-1.2.4b4.tar.gz

Terminal:
$ tar zxvf MySQL-python-1.2.4b4.tar.gz
$ cd MySQL-python-1.2.4b4
$ vim site.cfg
## Comment this line
#mysql_config = /usr/local/bin/mysql_config
## provide path to mysql_config
mysql_config = /usr/local/mysql/bin/mysql_config
$ python setup.py build
$ sudo python setup.py install

Looks good so far. Check if everything works
$ python
Python 2.7 (r27:82508, Jul  3 2010, 21:12:11) 
[GCC 4.0.1 (Apple Inc. build 5493)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import MySQLdb
>>> 

Rerun the Google App Engine.
I was not able to solve the problem. The ERROR message still stays the same.


__END__

No comments:

Post a Comment