Setting Up Google CourseBuilder in the PyCharm IDE on Mac OS X

There wasn’t a single source of information I could find to get CourseBuilder to work properly, so I decided to put together this guide in the chance that I need to go through the process again. I make no guarantee nor responsibility that it will work for anyone else. All I know is that it worked for me in my particular situation.

Step 1: Download ALL THE PROGRAMS!

CourseBuilder is based off of Python, so check to make sure Python is installed. CourseBuilder doesn’t play nice with version 3, so make sure you have a version of Python 2. By default, it should be included on Mac. I have version 2.7. Perfect!

PyCharm, my Python IDE of choice (since the others on my project are using it), can be found here.  Grab the Community Version 4.0.6. For some reason, PyCharm 4.5 doesn’t play nice with CourseBuilder.

To run CourseBuilder, you need to have the Google App Engine SDK. The Engine runs as the server of CourseBuilder. If I understand correctly, it would then be impossible to run without it. Download that here. Grab the “for Python” version.

Finally, download Google CourseBuilder here. I was having issues directly clicking “Export to GitHub,” so click on the Downloads page and download the latest zip version. At the time of writing, it was “Course Builder v1.8.0 (6 April 2015).” Check to make sure your copy has a “lib” folder. One time I downloaded it, there must’ve been a problem since it didn’t download the entire program.

Not necessarily required, but I ended up needing a basic text editor for one step. I recommend TextWrangler, which you can download here.

After downloading, move the applications that ask to be moved to your Applications folder. Apple sure makes installs easy. Now time to make everything play nice together!

Step 2: Set Up Run/Debugging in PyCharm

I used a lot of information from this website to figure this step out. It was written for Windows though, so I had to change a few things.

The first thing you’ll notice after you open PyCharm is a dialogue box that says “Do you want the application “PyCharm CE.app” to accept incoming network connections?” I believe you have to select yes for it to be able to work properly with Version Control, the updater, or some other programs.

Now to set up run/debugging:

  1. Open the GAE project in PyCharm:
    1. Select menu item File > Open…
    2. Select your base project folder (the one which contains an app.yaml file). For these examples I’ll refer to it as <myproject_path>.
  1. Add a new python configuration:
    1. Run > Edit Configurations…
    2. Click the green plus sign “+
    3. In the Add New Configuration list, select Python.
    4. Specify the configuration parameters:
      1. Name: GAE_config
        Choose a name, which we’ll refer to as GAE_config
      2. Script: <GAE_install_path>dev_appserver.py
        Here you need to enter the location of the dev_appserver.py file installed in your Google App Engine SDK. On Mac OS X the default installation is /Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/dev_appserver.py. We’ll refer to this location as <GAE_install_path>
      3. Script parameters:
        –automatic_restart=no –max_module_instances=”default:1″ .
        These are the minimum arguments needed for the debugging to work. Don’t ask, I don’t know why.
        Ensure you include the final argument, “
        .“: it means the current path, i.e. the working directory in this case.
      4. Working directory: <myproject_path>
      5. Tick the Share box.
        This creates configuration file <myproject_path>.idearunConfigurationsGAE_config.xml, which can be shared with other users and put in version control.
      6. Press OKgae-mac-preferences
  1. Check the python debugger settings:
    1. PyCharm > Preferences…
    2. Expand the tree to Build, Execution, Deployment > Python Debugger
    3. Ensure the option Attach to subprocess automatically while debugging is ticked.

At this point, the basic PyCharm configuration for python GAE debugging is done. To debug, add a breakpoint in the python file and run in debug mode. However, I had a few problems when I tried to run it.

First, I got an error that said lxml was missing.

Lxml is a library of some sort. PyCharm actually has a robust library import system built directly into it. To find it:

    1. PyCharm > Preferences…
    2. Expand the tree to Project:coursebuilder > Project Interpreter
    3. Check to see if lxml is included in the list of libraries.

In my case, it was missing, so I tried to add it to the libraries.

    1. Click the little “+” in the lower-left corner
    2. Type “lxml” in the search bar, and select it
    3. Click Install Packages.

I get a “pip could not be found” error. Great.

Pip is the Python library downloader. Apparently, it’s not included in Python 2.7 by default, so open up a Terminal and put the following command in:

sudo easy_install pip

It will then ask for your password, and install pip for you!

Trying the above method to install lxml, I received another error, and the only way I could figure out to install lxml was to use a workaround, utilizing xcode—the Apple development suite. I don’t know if it will work without xcode explicitly being installed on your machine or not.

sudo CPATH=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/libxml2 CFLAGS=-Qunused-arguments CPPFLAGS=-Qunused-arguments pip install lxml

Now my CourseBuilder website runs correctly! Press the green play button to run the server. To see your website, you click one of the three links will appear in the terminal. By default, it runs on port 8080.

Setting up auto complete, on the other hand, is another project for another day.

Leave a Reply

Your email address will not be published. Required fields are marked *