首页 > 代码库 > 配置Pycharm3.4.1调试edX Devstack
配置Pycharm3.4.1调试edX Devstack
前提:
1.安装好Ubuntu
2.在Ubuntn上利用vagrant+VirtualBox 搭建好了edX Developer Stack,并能成功访问
3.在Ubuntu下安装好了Pycharm-3.4.1并成功激活
4.将来在Ubuntu环境下开发
准备工作:
1.转换路径到本机/devstack/
2.开启vagrant,输入命令:
vagrantup
3.利用ssh连接vagrant,输入命令:
vagrantssh
4.给edxapp帐号一个密码,输入命令:
sudopasswd edxapp
(这里我输入的为edxapp)
开始配置Pycharm:
以上准备工作做完后,打开Pycharm,点击OpenDirectory,
选择本机/devstack/edx-platform,点击OK
项目打开了,会一直在从源代码管理获取代码,所以先关了源代码管理。
方法:打开“File”->”Settings”->”VersionControl”
然后在VCS下面选择none。
接下来配置Pycharm编译器:
依次打开File>Settings>ProjectInterpreter,在右侧ProjectInterpreter后面点配置图标AddRemoting,如下图
然后在ConfigureRemote Python Interpreter窗口内,选择SSHCredentials,Host输入127.0.0.1,端口输入2222,Username 输入edxapp,Authtype选择Password,Password输入文章开头改后的密码,勾选Savepassword,Pythoninterpreterpath选择后面的路径为/edx/app/edxapp/venvs/edxapp/bin/python,Pycharmhelperspath选择路径/edx/app/edxapp/edx-platform/.pycharm_helpers,然后点OK保存。配置成功后会包相关的包都引入,如下图
配置编译命令
依次打开菜单项Run>EditConfigurations,在打开的Run/DebugConfigurations窗口,左侧点击加号”+”>Python
在Name填入LMS,Script填入./manage.py,Scriptparameters填入lmsrunserver --settings=devstack 0.0.0.0:8000,Pythoninterpreter选择RemotePython 2.7.3(ssh://edxapp@127.0.0.1:2222:edx/app/edxapp/....),Workingdirectory选择/edx/app/edxapp/edx-platform,Pathmappings选择/devstack/edx-platform/=/edx/app/edxap/edx-playform/,取消勾选Addcontent roots to PYTHONPATH和取消勾选Addsource roots to PYTHONPATH,点击OK,保存设置。
然后先点击左侧LMS,然后点击减号”—”后面的Copy,在Name填入Studio,Scriptparameters改为cmsrunserver --settings=devstack 0.0.0.0:8001,点击OK,保存设置。
以上就完成了所有配置。
在Pycharm点击run/debug就可以看到http://0.0.0.0:8000或http://0.0.0.0:8001,在浏览器中输入即可访问,如果看到error111,请参考以下:
Most of the troubleshooting commands assume you are using the vagrant account. Press CTRL+D to return from the edxapp user to the vagrant user.
pymongo.errors.ConnectionFailure: could not connect to localhost:27017: [Errno 111] Connection refused
If you see this error when attempting to run the server then you need to remove the lock and restart mongodb. This error usually occurs when the VM is not shutdown properly. To avoid this problem in the future, use one of the vagrant commands to suspend the VM (e.g. vagrant halt or vagrant suspend). To fix the problem:
vagrant ssh
sudo rm /edx/var/mongo/mongodb/mongod.lock
sudo start mongodb.
配置Pycharm3.4.1调试edX Devstack