标签:
前提:
1.安装好Ubuntu
2.在Ubuntn上利用vagrant+VirtualBox 搭建好了edX Developer Stack,并能成功访问
3.在Ubuntu下安装好了Pycharm-3.4.1并成功激活
4.将来在Ubuntu环境下开发
准备工作:
1.转换路径到本机/devstack/
2.开启vagrant,输入命令:
vagrant up
3.利用ssh连接vagrant,输入命令:
vagrant ssh
4.给edxapp帐号一个密码,输入命令:
sudo passwd edxapp
(这里我输入的为edxapp)
开始配置Pycharm:
以上准备工作做完后,打开Pycharm,点击Open Directory,
选择本机/devstack/edx-platform,点击OK
项目打开了,会一直在从源代码管理获取代码,所以先关了源代码管理。
方法:打开“File”->”Settings”->”Version Control”
然后在VCS下面选择none。
接下来配置Pycharm 编译器:
依次打开File>Settings>Project Interpreter,在右侧Project Interpreter后面点配置图标Add Remoting,如下图
然后在Configure Remote Python Interpreter窗口内,选择SSH Credentials,Host输入127.0.0.1,端口输入2222,User name 输入edxapp,Auth type选择Password,Password输入文章开头改后的密码,勾选Save password,Python interpreter path选择后面的路径为/edx/app/edxapp/venvs/edxapp/bin/python,Pycharm helpers path选择路径/edx/app/edxapp/edx-platform/.pycharm_helpers,然后点OK保存。配置成功后会包相关的包都引入,如下图
配置编译命令
依次打开菜单项Run>Edit Configurations,在打开的Run/Debug Configurations窗口,左侧点击加号”+”>Python
在Name填入LMS,Script填入./manage.py,Script parameters填入lms runserver --settings=devstack 0.0.0.0:8000,Python interpreter选择Remote Python 2.7.3(ssh://edxapp@127.0.0.1:2222:edx/app/edxapp/....),Working directory选择/edx/app/edxapp/edx-platform,Path mappings 选择/devstack/edx-platform/=/edx/app/edxap/edx-playform/,取消勾选Add content roots to PYTHONPATH和取消勾选Add source roots to PYTHONPATH,点击OK,保存设置。
然后先点击左侧LMS,然后点击减号”—”后面的Copy,在Name填入Studio,Script parameters改为cms runserver --settings=devstack 0.0.0.0:8001,点击OK,保存设置。
以上就完成了所有配置。
在Pycharm 点击run/debug就可以看到http://0.0.0.0:8000或http://0.0.0.0:8001,在浏览器中输入即可访问,如果看到error 111,请参考以下:
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.
标签:
原文地址:http://www.cnblogs.com/cardgames/p/4206411.html