PyCharm

Some people like using PyCharm as an IDE. Here is some help on how to do that.

Using PyCharm at edX

Git

Using Git in PyCharm

You can set up PyCharm to help you manage your Git repositories under Preferences => Version Control => Git.  You can also choose which Git directories you want PyCharm to manage under the Preferences => Version Control tab by highlighting an "Unregistered root" and clicking the "+" (Add) button.

Push Rejected dialog

If you ever get a "Push Rejected" dialog, be sure not to choose to auto-update push with merge or rebase.  If you are unsure of your settings, double-check the following:

  • "Update method:" should be "Branch default"
  • "Auto-update if push of the current branch was rejected" should be unchecked

General Tips

Show open file in Navigator

A nice to have setting is to enable autoscrolling in the Project Navigation within PyCharm

  1. On the top of the Navigation pane, to the right of the "Project" selection, select the "Gear" icon.
  2. Enable "Always Select Opened File"

Now when you open a file it the Navigation pane will highlight that file.

Use the Hot Key combination "Cmd-Shift-O" to type and find a file.

Source Roots and Dependencies

If you want to get rid of the red underlines, and enable "Cmd-b" to work to get you to definitions, PyCharm needs to understand where the sources are for your import.

Take the root directory of the import statement, find its directory in the Project window, right-mouse click on the directory and choose "Mark Directory as" => "Sources Root". 

Running on a custom JDK

With PyCharm version >= 5, the IDE comes packaged with their own version of Java 8. To override/change that, see here: https://intellij-support.jetbrains.com/entries/23455956-Selecting-the-JDK-version-the-IDE-will-run-under

Note: before attempting to debug Open edX, you should follow these steps to run the LMS and Studio outside of the debugger:

https://github.com/edx/configuration/wiki/edX-Developer-Stack

PyCharm will only run the Python processes for you, and so doesn't do all of the initialization to compile SASS files etc.

Testing your changes

See the Test Engineering FAQ for all your questions about testing the edX platform.

Use Google Styled Docstrings

Go to Preferences → Tools → Python Integrated Tools → Doctrings and set the Docsring format.

Go to Code in Github Directly

If you right mouse click on a line of code, there is an option to "Open on Github". This will take you directly to the code and line in the commit you are working on in your browser.