本文介绍了在IntelliJ中调试Crossbar.io应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在IntelliJ中使用Crossbar.io构建一个应用程序。由于您在shell中使用 crossbar start 命令启动应用程序,我不清楚如何(理想地自动)将Python调试器附加到相应的脚本。任何人都有什么想法?

解决方案

很好的问题。



我对如何调试感到有些困惑,因为看起来crossbar是将python 2和3混合在一起的。我想使用Python 3在虚拟环境下安装crossbar.io,因为示例组件使用的是python 3,但是由于某种原因,我无法在虚拟环境中安装交叉开关,Python 3和Im强制使用Python 2进行WAMP路由代替。我通常使用而不是virtualenv,但是我相信他们都是类似的。我最终创造了2个pyenvs。一个与Python 2.7.6纯粹为crossbario路由器,另一个与Python 3.4.2的应用程序组件。



我的解决方案





我不知道这是否是解决这个问题的最佳方法,但这是我所做的。我使用PyCharm,但我相信IntelliJ也是类似的。



我没有在virtualenv下尝试过,但我认为这是非常相似的。


  1. 通过pyenv安装python 2.7.6

     
    $ pyenv install 2.7.6


  2. 使用Python 2为crossbar.io创建一个pyenv

     
    $ pyenv virtualenv 2.7.6 crossbar
    $ pyenv激活交叉栏
    (crossbar)$ pip install crossbar


  3. 查找并复制您刚才安装的crossbar可执行文件的完整路径。

     
    (crossbar) $ which crossbar

    并复制路径。


  4. 安装python 3.4.2通过pyenv

     
    $ pyenv install 3.4.2


  5. 使用Python 3为应用程序组件创建一个pyenv

     
    $ pyenv virtualenv 3.4.2 app
    $ pyenv activate app
    (app)$ pip install autobahn


  6. Cr使用app作为本地python环境来选择一个普通的PyCharm项目。我的意思是使用应用程序pyenv的python可执行文件作为解释器。


  7. 生成一个hello world crossbar.io应用程序。

     
    $ pyenv activate crossbar
    (crossbar)$ crossbar init --template hello:python



  8. 点击绿色+图标,然后选择Python

  9. 粘贴crossbar可执行脚本的完整路径。

     
    〜/ .pyenv / versions / crossbar / bin / crossbar


  10. 单词开始作为脚本参数。

  11. 确保选择crossbar作为Python解释器而不是应用程序。如果我错了,请更正我,但我相信我们在这里选择的解释器只是用于运行和调试目的,而不是代码完成和内容。

  12. 确保将.crossbar文件夹的路径放在位于工作目录路径。

  13. 访问0.0.0.0:8080以触发调试会话。


I'm building an app using Crossbar.io in IntelliJ. Since you start the app using the crossbar start command in the shell I'm not clear on how to (ideally automatically) attach the Python debugger to the appropriate scripts. Anyone have any ideas?

解决方案

Nice question.

I was a little bit confused about how to debug as well because it seems like crossbar is sort of mixing up python 2 and 3 together. I wanted to install crossbar.io under a virtual environment with Python 3 because the examples components are using python 3 but for some reason I could not manage to install crossbar under a virtual environment with Python 3 and Im forced to use Python 2 for WAMP routing instead. I normally use pyenv rather than virtualenv, however, I believe they both are similar. I ended up creating 2 pyenvs. One with Python 2.7.6 purely for crossbario router and the other with Python 3.4.2 for App Components.

My Solution

Have a look at the Screenshot

I don't know if it is the best way to solve this problem but this is what I did. I used PyCharm but I believe IntelliJ is similar as well.

I haven't tried this under virtualenv but I reckon it is quite similar.

  1. Install python 2.7.6 via pyenv

    $ pyenv install 2.7.6
    

  2. Create a pyenv with Python 2 for crossbar.io

    $ pyenv virtualenv 2.7.6 crossbar
    $ pyenv activate crossbar
    (crossbar)$ pip install crossbar
    

  3. Find and copy the full path for crossbar executable you have just installed.

    (crossbar)$ which crossbar
    

    and copy the path.

  4. Install python 3.4.2 via pyenv

    $ pyenv install 3.4.2
    

  5. Create a pyenv with Python 3 for app components

    $ pyenv virtualenv 3.4.2 app
    $ pyenv activate app
    (app)$ pip install autobahn
    

  6. Create a normal PyCharm project with "app" as a local python environment. I mean use python executable from app pyenv as an interpreter.

  7. Generate a hello world crossbar.io app.

    $ pyenv activate crossbar
    (crossbar)$ crossbar init --template hello:python
    

  8. From menubar go to Run/Edit configuration...

  9. Click a green + icon and select Python
  10. Paste the full path for crossbar executable script.

    ~/.pyenv/versions/crossbar/bin/crossbar
    

  11. put the word start as Script parameters.
  12. Make sure to select crossbar as a Python interpreter not app. Please correct me if Im wrong but I believe the interpreter we select here is only for running and debugging purpose not for code completion and stuffs.
  13. Make sure to put the path where .crossbar folder is located as a Working directory path.
  14. Visit 0.0.0.0:8080 to trigger the debug session.

这篇关于在IntelliJ中调试Crossbar.io应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-03 19:20
查看更多