`
顽石
  • 浏览: 163951 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类
最新评论

hadoop hue开发调试环境搭建

 
阅读更多

    hue系统后台主要使用 python语言,我们需要对 hue进行定制化二次开发。开发机操作系统为ubuntu12.04,使用独立的开发机器,小组其他人可共用。也可在自己平时使用的windows机器上开ubuntu虚拟机(如果机器配置较高),下面是hue开发环境的搭建过程。

  

   1.独立的开发机上不能使用图形环境,需要在自己的windows机器上安装Xming xwindow server软件,下载地址http://sourceforge.net/projects/xming/

     安装后,修改安装目录中的X0.hosts,在其中增加一行,内容为开发机的ip地址。

    启动windows上的Xming,这样开发机器上的eclipse启动后会将图形窗口投射到windows机器上。

         

  2.在开发机器上安装jdk1.7huehttps://github.com/cloudera/hue,版本3.7.0)、eclipse(4.3/kepler).

   假设hue安装在/home/wanggb/hue目录

   配置好hue后,在/home/wanggb/hue目录下运行build/env/bin/hue     runcherrypyserver命令启动hue,在浏览器中输入hue的ip和端口看是否能访问。

  3.在用户的.profile文件中加入环境变量DISPLAY,如下:

   export DISPLAY=windows机器的ip:0.0

   执行. .profile让环境变量生效。

  4.telnet到开发机上命令行方式启动eclipse,将会在windows机器上弹出eclipse图形窗口,提示设置workspace目录。

    5.安装pydev eclipse插件(http://pydev.org/updates)用于python开发调试。安装完成重启eclipse设置pydev插件,主要是设置python解释器。使用hue自带的python,为/home/wanggb/hue/build/env/bin/python2.7     

    

 
  

  6.eclipse中创建python django项目

     

 
     

       


 
 

 

  设置项目属性:      


   

   设置项目的debug配置:

    

 主模块设为buid/env/bin/hue,在有些eclipse中会报找不到该文件的提示,此时可以将hue拷贝为hue.py,刷新项目后再用Main Module右边的Browse按扭选取该hue.py,或直接输入${workspace_loc:hue/build/env/bin/hue.py}做为主模块。

 
 

   7.打开pyDev透视图

 

 
 

   8.修改hue的一处代码

  修改文件为:hue/desktop/core/src/desktop/appmanager.py

    改动其中的import_module_or_none方法为如下,在my_file = re.sub(r'\.pyc','.py', __file__)

    语句后面直接return None

 def _import_module_or_none(module):

  """Like import_module, but returns None if the module does not exist.

  This will properly handle nested ImportErrors in such a way that, if the

  module should exist but throws ImportError, we *will* raise through

  that error.

  """

  try:

    __import__(module)

    return sys.modules[module]

  except ImportError, ie:

    # If the exception came from us importing, we want to just

    # return None. We need to inspect the stack, though, so we properly

    # reraise in the case that the module we're importing triggered

    # an import error itself.

    tb = sys.exc_info()[2]

    top_frame = traceback.extract_tb(tb)[-1]

    err_file = re.sub(r'\.pyc','.py', top_frame[0])

    my_file = re.sub(r'\.pyc','.py', __file__)

    return None

    不修改的话在eclispe中调试时,会报错"ImportError: No module named settings"

 

   8 .python代码中设置断点,启动debug配置进行调试。

 

  9.上面的是本机调试,只是使用xwindoweclipse图形窗口投射到windows机器上,也可在自己的windows机器上起ubuntun虚拟机,这样就不需要xwindow了。

 

 

 10.pydev插件也可进行python远程调试,详细说明见http://pydev.org/manual_adv_remote_debugger.html。 

 

 11.图形化的python开发调试工具,除了eclispe+pydev,比较不错的还有pycharm ,可在     https://www.jetbrains.com/pycharm/download/下载。

  • 大小: 6.7 KB
  • 大小: 132.8 KB
  • 大小: 41.5 KB
  • 大小: 71.8 KB
  • 大小: 55.3 KB
  • 大小: 181.3 KB
  • 大小: 82.2 KB
  • 大小: 46.8 KB
分享到:
评论
3 楼 liangzai_bj 2015-09-23  

是我的配置有问题,我重新按博主的博客配置了下,不报错了!
2 楼 liangzai_bj 2015-09-23  

是我的配置有问题,我重新按博主的博客配置了下,不报错了!



liangzai_bj 写道
启动后,报个错?
pydev debugger: starting (pid: 2872)
Traceback (most recent call last):
  File "/Users/liangzai/soft/java/Eclipse.app/Contents/Eclipse/plugins/org.python.pydev_4.3.0.201508182223/pysrc/pydevd.py", line 2283, in <module>
    globals = debugger.run(setup['file'], None, None)
  File "/Users/liangzai/soft/java/Eclipse.app/Contents/Eclipse/plugins/org.python.pydev_4.3.0.201508182223/pysrc/pydevd.py", line 1709, in run
    pydev_imports.execfile(file, globals, locals)  # execute the script
IOError: [Errno 2] No such file or directory: '/Users/liangzai/soft/java/eclipse-workspace/hue-3.7.0-cdh5.4.2/manage.py'

1 楼 liangzai_bj 2015-09-22  
启动后,报个错?
pydev debugger: starting (pid: 2872)
Traceback (most recent call last):
  File "/Users/liangzai/soft/java/Eclipse.app/Contents/Eclipse/plugins/org.python.pydev_4.3.0.201508182223/pysrc/pydevd.py", line 2283, in <module>
    globals = debugger.run(setup['file'], None, None)
  File "/Users/liangzai/soft/java/Eclipse.app/Contents/Eclipse/plugins/org.python.pydev_4.3.0.201508182223/pysrc/pydevd.py", line 1709, in run
    pydev_imports.execfile(file, globals, locals)  # execute the script
IOError: [Errno 2] No such file or directory: '/Users/liangzai/soft/java/eclipse-workspace/hue-3.7.0-cdh5.4.2/manage.py'

相关推荐

Global site tag (gtag.js) - Google Analytics