Anyone using JetBrains Pycharm to run/debug the platform?

2,535 views
Skip to first unread message

Abdallah Nassif

unread,
Dec 25, 2013, 6:24:34 AM12/25/13
to edx-...@googlegroups.com
Hello,

Im wondering if someone successfully setup the platform to run or to be debugged from Pycharm. If so, I would appreciate if they could share how it was setup?

Thanks,

Abdallah

Chris Dodge

unread,
Dec 27, 2013, 4:08:01 PM12/27/13
to edx-...@googlegroups.com
I know a few people here at edX use Eclipse as a more 'full featured' IDE for writing/debugging the platform. I believe we get asked this question a few times, so it's probably worth someone's time to jot down some notes, as - or so I recall - it was a somewhat complicated setup.

Unfortunately, I just use a plain vanilla text editor to do my work, so I won't be able to assist.

- Chris

Abdallah Nassif

unread,
Dec 29, 2013, 8:36:17 AM12/29/13
to edx-...@googlegroups.com
ok.... so after a bizillion trials i finally figured this out. ill write this as a set of steps, if it helps anyone.

1- open the run/debug configuration window

2- add a new django server from the green plus sign and name it what ever you want

3- clear the "Host" and "Port" fileds (Very important since pycharm will add double quotation before your port settings and mess-up your run/debug command)

4- in "Additinal options" type: --settings=dev runserver 127.0.0.1:8001

5- check the "Custom run command" option and set it as cms

6- click the run or debug and enjoy


I find it very helpful since you can debug and check all your variable instead of a mess using print statements and chasing your console window.

Hope this helps!

Abdallah

Thomas Brennan-Marquez

unread,
Dec 31, 2013, 5:32:45 PM12/31/13
to edx-...@googlegroups.com
Thanks for this, Abdallah. 

When I try to run it in PyCharm I get an error: Restart Error/Please select Django module

I must have missed something.

Thomas

Abdallah Nassif

unread,
Jan 2, 2014, 7:41:34 AM1/2/14
to edx-...@googlegroups.com
Thomas,

Did you enable django support in the pycharm settings? i ddnt mention this part since it should be configured to any django app you use.

if you need help with that, ill edit the steps to start from when you first open the project if that helps.

Abdallah

Chris Dodge

unread,
Jan 2, 2014, 7:56:12 AM1/2/14
to edx-...@googlegroups.com
Hi Abdallah,

Thanks for these steps. Any chance you could get them on the edx-platform Wiki: https://github.com/edx/edx-platform/wiki?

Thanks

Thomas Brennan-Marquez

unread,
Jan 3, 2014, 4:16:30 PM1/3/14
to edx-...@googlegroups.com

Abdallah,

I looked for a place to enable django support in PyCharm but didn't find any. If you wouldn't mind writing out a detailed description I'm pretty sure it would help me--and I'm very sure it will help the next developer who wants to do this. I'll make you a deal: if you'll write out the steps I'll plug your description into the wiki as Chris has requested.  :)


Thomas


On Wednesday, December 25, 2013 3:24:34 AM UTC-8, Abdallah Nassif wrote:

hafizhuddin amin

unread,
Jan 4, 2014, 10:01:40 PM1/4/14
to edx-...@googlegroups.com
django support is not available on Community Edition, afaik

Abdallah Nassif

unread,
Jan 5, 2014, 5:45:39 AM1/5/14
to edx-...@googlegroups.com
Chris,

Yes no problem. I'll post the steps here and you can just copy them or will send them to you directly if thats more convenient.


Thomas,

No problem. its just a couple of steps to enable django support, ill add those in a bit.


Haffizhuddin,

I dont know about the community edition. I purchased the full version of pycharm, I think its worth the money!

Center for Workforce Development

unread,
Jun 6, 2014, 4:19:00 PM6/6/14
to edx-...@googlegroups.com
I would like to know how to debug a remote production stack instance.  After following devstack debug instructions for Pycharm https://github.com/edx/edx-platform/wiki/Developing-on-the-edX-Developer-Stack#debugging-the-devstack-image I got lost as what to do with the "Script Parameters" for the "manage.py" script since devstack indicates that it's 

Specify "lms runserver --settings=devstack 0.0.0.0:8000" for "Script parameters"

It looks like the production stack https://github.com/edx/configuration/wiki/edX-Managing-the-Production-Stack#restarting-services manages the lms/cms services through supervisorctl command.  Can someone redirect me to debug configuration for remote production install of edX?

Ned Batchelder

unread,
Jun 6, 2014, 5:33:51 PM6/6/14
to edx-...@googlegroups.com
I hope this doesn't sound odd, but we don't know your name: your email is named for an organization, and you don't sign your messages. :)

--Ned.​

Zachary Trabookis

unread,
Jun 28, 2014, 1:17:31 PM6/28/14
to edx-...@googlegroups.com
Ned,

I'm going to start posting as myself for Center for Workforce Development.  Any ideas on how to setup https://github.com/edx/edx-platform/wiki/Developing-on-the-edX-Developer-Stack#create-debug-configuration-lms-studio-for-pycharm for production stack.  I setup a prodstack and want to debug it remotely using PyCharm.

Zach

Bob Light

unread,
Jul 3, 2014, 12:53:53 PM7/3/14
to edx-...@googlegroups.com
Here is what I used to get started with PyCharm to debug both Studio and LMS  (as well as xblock's workbench)



 - Bob Light

Jay Zoldak

unread,
Jul 3, 2014, 1:01:52 PM7/3/14
to edx-code
Mihn from the TestEng team also just put together a wiki page specifically on Setting up PyCharm for edX development
We still need to reconcile with the info on the Developing on the edX Developer Stack page and remove any duplicated / out-of-date info from there.

-- JZ

Peter Wilkins

unread,
Aug 3, 2014, 7:07:55 PM8/3/14
to edx-...@googlegroups.com
Have people who followed the these recommendations find that "Find Usages" and "Goto Declaration" work for them?

Thank you,
peter

Brandon DeRosier

unread,
Aug 3, 2014, 7:41:39 PM8/3/14
to edx-...@googlegroups.com
Hi Peter, I followed the guide about a month ago for the edX devstack and the features that you listed functioned well along with remote debugging.

- Brandon

Brandon DeRosier

unread,
Aug 4, 2014, 1:52:50 AM8/4/14
to edx-...@googlegroups.com
I followed the linked guide tonight and it appears to be missing a step or two.

In order for PyCharm to have the necessary context for basic plumbing, several directories must be flagged as source directories, including:
  • cms/djangoapps
  • cms/lib
  • lms/djangoapps
  • lms/lib
  • common/djangoapps
  • common/lib
To add a directory to the source directory list, *right click* >> Mark Directory As >> Sources Root.
The list can also be modified from within File >> Settings... >> Project Settings >> Project Structure.

- Brandon

Peter Wilkins

unread,
Aug 4, 2014, 1:10:34 PM8/4/14
to edx-...@googlegroups.com
Thanks, Brandon.  That did the trick!

- peter

Randy Ostler

unread,
Sep 2, 2014, 5:55:26 PM9/2/14
to edx-...@googlegroups.com
Thanks for the wiki setup explanation.  I'm just a little confused.  I have no frames in my Frames - frame, and therefore no variables to observe.  Am I doing something wrong?  I was able stop at a breakpoint in the views.py file.  How do I evaluate things?  Thanks!

Ivica Ceraj

unread,
Sep 2, 2014, 6:25:31 PM9/2/14
to edx-...@googlegroups.com
I followed manual on:
  https://github.com/edx/edx-platform/wiki/Setting-up-PyCharm-for-edX-development

And was able to debug a module using PyCharm on Mac with edX in VirtualBox. Worked fine.

Thomas Brennan-Marquez

unread,
Sep 2, 2014, 7:09:47 PM9/2/14
to edx-...@googlegroups.com
Randy,

It sounds like you haven't started running the debugger or possibly haven't yet hit a breakpoint. If the system is running you should be able to talk to the server at 8000 or 8001 just like you can when you run either LMS or CMS via paver in a terminal window. If things are working you should see all those same lines of activity showing up in the Console window in PyCharm as you do in the terminal window. If that's all okay, you need to set a breakpoint at a line of code you know you will hit when you request something from the server. When I first tried to get PyCharm running CMS this trivial-sounding task turned out to be harder than I thought. Reply back if you need help finding such a line.

Thomas

Dmitry Ivanyushin

unread,
Sep 9, 2014, 9:13:59 AM9/9/14
to edx-...@googlegroups.com
This is interesting.

I remember there was old version of this I page, which I followed something like in July, and I could happily debug platform using breakpionts etc. Somehow, when I updated core edx-platform files from master, my debug configuration stopped working, and it still does not work, even when I did everything from scratch.

@edx-team Any ideas what happened? Current version of this tutorial does not work for me.

среда, 3 сентября 2014 г., 2:25:31 UTC+4 пользователь Ivica Ceraj написал:

Thomas Brennan-Marquez

unread,
Sep 9, 2014, 9:47:37 AM9/9/14
to edx-...@googlegroups.com
Be sure you go through the steps to set up PyCharm's remote interpreter. The old one won't work when you get a new VM image. Do that first, then continue on to create a debugging configuration which uses that new interpreter. I've been through this cycle many times now.

Dmitry Ivanyushin

unread,
Sep 10, 2014, 5:49:20 AM9/10/14
to edx-...@googlegroups.com
I did not use any of edx images, I installed edx-platform with dev configuration on vanilla Ubuntu (that was long ago in july, I am still using that image of mine). Of course, I am using vagrant to virtualize. I recreated remote interpreter configuration (with deletion/creation py helpers) many times but no luck with this.

Interesting fact. When I start debug and immediately finish it while pratform in loading process, debugger can catch the trace and I can see line and scope where debug process has ended. But still no preakpoint stops or anything.

May be, when I have more time, I will try recreate image from scratch and debug setup. But something hints me that I wont have any joy with this. :)

вторник, 9 сентября 2014 г., 17:47:37 UTC+4 пользователь Thomas Brennan-Marquez написал:

Ben Patterson

unread,
Sep 10, 2014, 8:03:53 AM9/10/14
to edx-...@googlegroups.com
Hi Dmitry - 

I'm guessing you're using paver commands? Have you tried setting a breakpoint manually (e.g., modifying the code at the location you want a breakpoint)?

Sometimes the Jetbrains debugger will not attach on internals that are called by that command (e.g., child processes such as a test run). It is not as fluid, I agree, but you can manually set breakpoints with set_trace(). There's a note about that at the bottom of that wiki page.

Thomas Brennan-Marquez

unread,
Sep 10, 2014, 11:58:56 AM9/10/14
to edx-...@googlegroups.com
Dmitry,

Another thing to check: as you start up the debugger, watch the console window (lower right corner of the screen) specifically looking for a message saying something like 'failed to set breakpoint...' I've seen that happen when I setup the remote interpreter incorrectly (wrong port, etc.) and also when I don't get the connection between the configuration and the interpreter right. The first clue that I made a mistake like that is that the code doesn't stop at a breakpoint when expected.

T.

Dmitry Ivanyushin

unread,
Sep 11, 2014, 9:19:19 AM9/11/14
to edx-...@googlegroups.com
No, breakpoint setups in IDE give no error. When I launch configuration I can clearly see messages as "Debugger connected".

It is all like:

ssh://edx...@127.0.0.1:2230/edx/app/edxapp/venvs/edxapp/bin/python -u /edx/app/edxapp/edx-platform/.pycharm_helpers/pydev/pydevd.py --multiproc --client '0.0.0.0' --port 48025 --file /edx/app/edxapp/venvs/edxapp/bin/paver lms --settings=ifmo.devstack --fast
pydev
debugger: process 13974 is connecting


Connected to pydev debugger (build 135.1057)
---> pavelib.servers.lms
---> pavelib.prereqs.install_prereqs
Enter CTL-C to end
Validating models...


0 errors found
Django version 1.4.12, using settings 'lms.envs.ifmo.devstack'
Development server is running at http://0.0.0.0:8000/
Quit the server with CONTROL-C.


среда, 10 сентября 2014 г., 19:58:56 UTC+4 пользователь Thomas Brennan-Marquez написал:

Andy Armstrong

unread,
Sep 11, 2014, 10:09:14 AM9/11/14
to edx-...@googlegroups.com
Hi Dmitry,

The updated developer instructions are incorrect as you've discovered. They suggest that you run Paver commands in your debug configurations, but unfortunately that in turn starts another process which PyCharm is not able to debug. We have spoken to JetBrains and they inform us that a future release will support for debugging through into subprocesses, but there is no ETA yet. We need to revert the instructions back to the way they were.

I'll go and update the wiki shortly, but in the meantime here are the settings I'm using to run LMS and Studio from PyCharm:

Inline image 1

Inline image 2

The rest of the wiki instructions are correct, so all you should need to do is change the script and script parameters that you specify.

Let me know if this works for you.

 - Andy
--

Andy Armstrong

edX | UI Architect  | an...@edx.org  

141 Portland Street, 9th floor

Cambridge, MA 02139

http://www.edx.org

http://www.e-learn.nl/media/blogs/e-learn/edX_Logo_Col_RGB_FINAL.jpg?mtime=1336074566

Dmitry Ivanyushin

unread,
Sep 12, 2014, 2:23:27 AM9/12/14
to edx-...@googlegroups.com
Hi, Andy.

I was guessing that switching to manage.py could be solution, but haven't tried it out till you hinted me. This did the trick. I can debug with PyCharm again. Problem solved, Thank you. :)

четверг, 11 сентября 2014 г., 18:09:14 UTC+4 пользователь Andy Armstrong написал:

Randy Ostler

unread,
Sep 12, 2014, 9:56:40 AM9/12/14
to edx-...@googlegroups.com
Thanks Thomas.  Yes that was what was happening.  The problem was it wasn't finding my breakpoints because there was a problem with path mappings.
I'm still working that out.


Thanks for your help.


Randy Ostler

unread,
Sep 12, 2014, 10:10:22 AM9/12/14
to edx-...@googlegroups.com


Thanks Andy!

If I don't set breakpoints, It runs fine.

I put a break in line 10 of urls.py in the lms directory and I am:
trying to add breakpoint to file that does not exist: /vagrant/edx-platform/lms/urls.py

I think it is getting the /vagrant root from the VagrantFile?

Is there an environment variable that I need to set to go the right way?

Thanks

Thomas Brennan-Marquez

unread,
Sep 12, 2014, 11:43:32 AM9/12/14
to edx-...@googlegroups.com
I've seen this happen when something is wrong with the connection between the remote interpreter and the configuration--usually because I screwed up some setting somewhere when setting either of those things up. The fact that you are getting it to run at all says the remote interpreter is setup okay. Probably your run configuration is slightly wrong. I'd double check the path mappings 

'myEdxPlatform' maps to '/edx/app/edxapp/edx-platform'

where 'myEdxPlatform' is the folder where you normally go to see/edit manage.py--outside the virtual machine, just with your operating system's usual file finding tool.

If that is set correctly, I'd build a new configuration following the directions on the wiki page, being very careful to get everything exactly right.

Good luck,
Thomas

Randy Ostler

unread,
Sep 12, 2014, 12:24:32 PM9/12/14
to edx-...@googlegroups.com
Thanks Thomas - 
Yes it is squirrely.  (I don't know why squirrels are taking the blame for this.)
my path mapping is:
local: /home/randy/edx/devstack/edx-platform  (whereinlies manage.py
remote: /edx/app/edxapp/edx-platform

When I set a break in /home/randy/edx/devstack/edx-platform/lms/urls.py it fails to fiind
/vagrant/edx-platform/lms/urls.py

As I don't have that in the path anywhere - it seems it is picking it up from a shell somewhere.  (I'm using ubuntu precise and remoting into a vagrant shell)
The only place I can find a /vagrant directive is in the Vagrantfile: config.vm.synced_folder ".", "/vagrant", disabled: true

There is a switch for the VAGRANT_USE_VBOXFS that hard codes everything if it is TRUE.  I don't have that set to be true.

I don't know much about vagrant, or the shells and environment variables being used in the remote debugger process.  

Any help would be greatly appreciated.

Randy

Thomas Brennan-Marquez

unread,
Sep 12, 2014, 12:35:54 PM9/12/14
to edx-...@googlegroups.com
​I haven't had to mess with any switches to get things to work. Not to say you won't but I would look elsewhere first.

Try setting a breakpoint in a different file. See if that one works. Here's one I know should be hit when you run Check on, say, a dropdown question in Studio:

/Users/trbm/_WORK_/OLIAS/devstack23/edx-platform/common/lib/capa/capa/responsetypes.py
first line of __init__ in class LoncapaResponse -- happens to be line 151 in my copy of the file

If you can set a breakpoint there without the error message that the file can't be found, try to open studio, run Check on any simple problem type and you should stop. If that works, you may have to mess with the env variables, switches, etc. If it doesn't work, I'd bet the configuration is still not right. Send me a bitmap snapshot of your configuration setup dialog and I'll look it over for you.

T.

Randy Ostler

unread,
Sep 12, 2014, 1:09:16 PM9/12/14
to edx-...@googlegroups.com
Thanks Thomas,

I'll try and do that.
I removed the vagrant plugin from Pycharm and rebooted Pycharm and now it is searching for files in /home/randy/edx/devstack/edx-platform/lms/urls.py and complains that the file doesn't exist.  That file exists in the mirrored environment, but it's clearly not the remote path.  

I'll follow your instructions about changing the breakpoint.

Randy Ostler

unread,
Sep 12, 2014, 1:14:33 PM9/12/14
to edx-...@googlegroups.com
When I set the breakpoint - I get the same warning: trying to add breakpoint to file that does not exist: /home/randy/edx/...

It seems to be completely ignoring the mappings.

Randy Ostler

unread,
Sep 12, 2014, 1:59:45 PM9/12/14
to edx-...@googlegroups.com
SOLVED!

In the Run/Debug Conigurations - the path mappings need to end with '/'
Oddly, it won't keep the local  slash there, but it will keep the remote.

I changed the local, and it finally started searching the remote file structure - but got confused with edx-platformcommon

When I added the remoted backslash it finds the files and stops giving me warnings.

In a couple of months, I will have hair again.

محمد القصير

unread,
Mar 30, 2018, 4:31:00 PM3/30/18
to General Open edX discussion

hello guys
any one can tell me how run edx open source form pycharm on ubuntu

Clinton Blackburn

unread,
Mar 30, 2018, 6:45:34 PM3/30/18
to General Open edX discussion
See the README in https://github.com/edx/devstack.

Clinton
Reply all
Reply to author
Forward
0 new messages