Setting up Python, Django, App Engine and Kate on Debian stable (7.0)
My desktop PC runs Debian stable. It defaults to Python 2.6. Google’s App Engine runs under Python 2.7. This article describes how to setup Python 2.7, Django 1.5, App Engine SDK for Python and the excellent Python editor Kate for Debian.
After doing some Googling, I found out an easy way to install Python 2.7 on Debian. Go to Applications->Accessories->Terminal and type in the following commands:
sudo apt-get install build-essential libsqlite3-dev zlib1g-dev libncurses5-dev libgdbm-dev libbz2-dev libreadline5-dev libssl-dev libdb-dev
tar -xzf Python-2.7.5.tgz
./configure --prefix=/usr --enable-shared
sudo make install
sudo update-alternatives --install /usr/bin/python python /usr/bin/python2.6 20
sudo update-alternatives --install /usr/bin/python python /usr/bin/python2.7 10
sudo update-alternatives --set python /usr/bin/python2.6
sudo ln -s python2.6 python
That last step, of linking python to python2.6 is necessary because some Debian packages insist that it not be a link to /etc/alternatives/python.
Now that Python 2.7 is setup, use the command python2.7 instead of just python to run any App Engine Python files.
App Engine and Django
Next, download the Google App Engine SDK for Python. It should download to your Downloads folder. In Terminal, run the following commands to install it in
sudo unzip ~/Downloads/google_appengine_1.8.0.zip
Right now, version 1.8.0 is the latest version of the SDK. If you downloaded a newer version, change the version number to match.
Next, we need to update our
~/.profile to point our
PYTHONPATH to the App Engine and Django packages. Using
vi or another text editor, load
~/.profile and add the following lines:
# Add App Engine and Django to Python
Now, log out of Gnome and log back in. This is necessary so that Kate will get the updated
PYTHONPATH when we install and run it.
Kate is an excellent Python editor. Python projects are saved as sessions. If you remember to save your session, before you exit Kate, Kate your session will be fully restored when you load Kate back up again.
To install Kate, go to System->Administration->Software Center and type kate in the search area. Kate if the first app that shows up. Click on the Install button to install Kate. This installs Kate but it doesn’t install Konsole and KDE Help Center, which Kate uses for a terminal and it’s help documentation.
To install Konsole, type konsole in Software Center’s search area. Konsole will be the first app that shows up. Click the Install button to install Konsole. To install the KDE Help Center, type khelp in the search area. Help Center (khelpcenter4) will be the first app that shows up. Click the Install button to install the KDE Help Center.
Once this is all done, Kate is fully installed. However, Kate does not show up in any of the Applications menus. To fix this load System->Preferences->Main Menu and highlight Accessories.
Here, you can see that Kate needs to be checked. Click the Close button to save the changes. Now you can load Kate from the Applications->Accessories menu.
Writing your first Django web app with Google App Engine, part 1
If you’ve been following my tutorial, you’ll note that the instructions are for the Mac. On Debian, you can use Kate to do everything. Just be sure and use python2.7 instead of python when following the instructions.
You’ll note that the deployment step, which deploys the PollApp to Google’s App Engine is done using the Mac (or Windows) GoogleAppEngineLauncher. There is no such beast for Linux. Instead, use Kate’s Terminal and issue the following commands to deploy:
python2.7 /usr/local/google_appengine/appcfg.py update .
Once that is finished, you can go to http://your-app-id.appspot.com/ and see the default Django web app in action.
In future tutorials, I’ll include instructions for using Kate to do everything.