在程序在pydev / eclipse中终止之前获取消息“此时无法显示控制台”

时间:2022-05-07 21:06:38

I have a project in pydev / eclipse that has multiple python files in the /src folder.

我在pydev / eclipse中有一个项目,在/ src文件夹中有多个python文件。

When I run the first program I created, it runs fine and I am able to interact with it in the console pane.

当我运行我创建的第一个程序时,它运行正常,我可以在控制台窗格中与它进行交互。

When I try to run any of the others

当我尝试运行其他任何一个时

no consoles to display at this time

此时无法显示任何控制台

flashes up but then the program quickly terminates before I can type anything. I can't reproduce it, but sometimes my first input question will flash by too.

闪烁,但程序很快就会终止,然后才能输入任何内容。我无法重现它,但有时我的第一个输入问题也会闪现。

If I go back to the first program I wrote, it runs fine even though it failed previously on the other programs.

如果我回到我写的第一个程序,它运行正常,即使它先前在其他程序上失败了。

When I run in debug mode, it usually works fine.

当我在调试模式下运行时,它通常可以正常工作。

How do I fix it so I can interact w/ my program in the console when I hit "run"?

我如何修复它,以便在我点击“运行”时可以在控制台中与我的程序进行交互?

This is what I have tried:

这是我尝试过的:

(1) closed eclipse and then restarted it

(1)关闭eclipse然后重新启动它

(2) checked that the "allocate console" was selected under run > run configurations > common menu option

(2)检查在运行>运行配置>常用菜单选项下是否选择了“分配控制台”

(3) unchecked the "allocate console" option, ran the program, then selected the "allocate console" option again

(3)取消选中“allocate console”选项,运行程序,然后再次选择“allocate console”选项

(4) tried window > show view > console menu option

(4)试过窗口>显示视图>控制台菜单选项

(5) restarted my computer

(5)重启我的电脑

(6) closed eclipse, moved my python files to the desktop, deleted the .metadata folder, deleted the project folder, restarted eclipse, changed the perspective, created a new project, imported my files into the newly created project

(6)关闭eclipse,将我的python文件移动到桌面,删除.metadata文件夹,删除项目文件夹,重启eclipse,更改透视图,创建新项目,将我的文件导入新创建的项目

(7) tried the stuff mentioned on the stack overflow page at No console output in Eclipse Juno. However, I did not understand the server suggestions. Where would I find that? I didn't think I was running one.

(7)尝试在Eclipse Juno中没有控制台输出的堆栈溢出页面上提到的东西。但是,我不明白服务器的建议。我会在哪里找到的?我不认为我在跑一个。

I have not uninstalled eclipse and python and then reinstalled both, but I am getting desperate so I might. Or I may just try to live with using debug to run the program.

我没有卸载eclipse和python,然后重新安装了两者,但我变得绝望,所以我可能。或者我可能只是尝试使用调试来运行程序。

I would like to know what is wrong though. I have used other workspaces with multiple python programs in the project with no problem.

我想知道出了什么问题。我在项目中使用了其他工作区和多个python程序,没有任何问题。

Thanks in advance for your help.

在此先感谢您的帮助。

1 个解决方案

#1


0  

I had the exact same problem. Reading about the OP attempts I went to Run => Run configurations. Under Ruby scripts it lists all my classes. If I select the class that "starts" everything as the "Launch script' it works. I love it when that happens. As for how the other classes' "Launch scripts" relate or what that is all about I have no clue. What I can tell you for sure is Eclipse "launches" whatever "tab" is open for the script your are editing and fails except in debug where it seems to be able to find what you want for some reason. Of course then in debug I find the console fails, but I digress.

我有同样的问题。阅读OP尝试我去Run =>运行配置。在Ruby脚本下,它列出了我的所有类。如果我选择“启动”所有内容的类作为“启动脚本”它可以工作。当发生这种情况时,我喜欢它。至于其他类的“启动脚本”如何关联或者是什么,我不知道。我可以肯定地告诉你,Eclipse“启动”任何“tab”都是为你正在编辑的脚本打开并失败,除了在调试中它似乎能够找到你想要的东西。当然然后在调试中找到控制台失败了,但我离题了。

Playing around with this a bit more I find once I start attempting to launch various other class scripts as if I expected them to work (in Run configurations); When I am in the edit tab of the script that is supposed to start everything... now it puts up choices for the one that starts everything or the others that should never work. It never did that when it was just flat out failing. This "fail forward" I find typical of Eclipse where you get nothing and then you stumble on something eventually (some times days later) it gives you a hint what you need to do.

一旦我开始尝试启动各种其他类脚本,就像我期望它们一样工作(在运行配置中);当我在应该启动所有内容的脚本的编辑选项卡中时...现在它为启动所有内容或其他应该永远不会工作的内容提供选择。当它刚刚失败时,它从未这样做过。这种“失败的前进”我发现Eclipse的典型特征是你什么也得不到,然后你最终偶然发现了某些东西(有时几天)它会给你一个暗示你需要做什么的提示。

I am sure this is all working as documented but the takeaway in this case is if it is not working it is because you are doing it wrong.

我确信这一切都是有记录的,但在这种情况下,如果它不起作用,那就是因为你做错了。

Update: Not being able to use the eclipse console in debug was my lack of knowledge. Here is the code that works as expected:

更新:无法在调试中使用eclipse控制台是我缺乏知识。以下是按预期工作的代码:

def user_options(text_area)
  puts <<-DELIMITER
  1. Include additional search pattern
  2. Delete all excluded text
  3. Delete all not excluded text
  4. Write! to file\n
    DELIMITER
  ARGF.each do |selection| 
    # increase scope to instance variable if needed!        
    @selection = selection.chomp!
    # only read one line                                                          
    break                       
  end
  case @selection
    when "1"                  
    @file_manager = FileManager.new
    current_file = @file_manager.send(:file_history_current)                                  
    when "2"
    ...
    else
      puts("Exiting")
      exit
  end
end

ARGF is your friend. It is not clear in the documentation but it works just like you would expect it to in 'C' (this is Ruby however). Remember that Ruby loves [] and you should be able to figure out most anything.

ARGF是你的朋友。它在文档中并不清楚,但它的工作方式与您在'C'中所期望的一样(但这是Ruby)。请记住,Ruby喜欢[],你应该能够弄清楚任何事情。

arguments = [arg1, arg2, arg3]
text_lines = @file_manager.send(:file_open, *arguments) 

def file_open(arg1, arg2, arg2)
  ...
end

#1


0  

I had the exact same problem. Reading about the OP attempts I went to Run => Run configurations. Under Ruby scripts it lists all my classes. If I select the class that "starts" everything as the "Launch script' it works. I love it when that happens. As for how the other classes' "Launch scripts" relate or what that is all about I have no clue. What I can tell you for sure is Eclipse "launches" whatever "tab" is open for the script your are editing and fails except in debug where it seems to be able to find what you want for some reason. Of course then in debug I find the console fails, but I digress.

我有同样的问题。阅读OP尝试我去Run =>运行配置。在Ruby脚本下,它列出了我的所有类。如果我选择“启动”所有内容的类作为“启动脚本”它可以工作。当发生这种情况时,我喜欢它。至于其他类的“启动脚本”如何关联或者是什么,我不知道。我可以肯定地告诉你,Eclipse“启动”任何“tab”都是为你正在编辑的脚本打开并失败,除了在调试中它似乎能够找到你想要的东西。当然然后在调试中找到控制台失败了,但我离题了。

Playing around with this a bit more I find once I start attempting to launch various other class scripts as if I expected them to work (in Run configurations); When I am in the edit tab of the script that is supposed to start everything... now it puts up choices for the one that starts everything or the others that should never work. It never did that when it was just flat out failing. This "fail forward" I find typical of Eclipse where you get nothing and then you stumble on something eventually (some times days later) it gives you a hint what you need to do.

一旦我开始尝试启动各种其他类脚本,就像我期望它们一样工作(在运行配置中);当我在应该启动所有内容的脚本的编辑选项卡中时...现在它为启动所有内容或其他应该永远不会工作的内容提供选择。当它刚刚失败时,它从未这样做过。这种“失败的前进”我发现Eclipse的典型特征是你什么也得不到,然后你最终偶然发现了某些东西(有时几天)它会给你一个暗示你需要做什么的提示。

I am sure this is all working as documented but the takeaway in this case is if it is not working it is because you are doing it wrong.

我确信这一切都是有记录的,但在这种情况下,如果它不起作用,那就是因为你做错了。

Update: Not being able to use the eclipse console in debug was my lack of knowledge. Here is the code that works as expected:

更新:无法在调试中使用eclipse控制台是我缺乏知识。以下是按预期工作的代码:

def user_options(text_area)
  puts <<-DELIMITER
  1. Include additional search pattern
  2. Delete all excluded text
  3. Delete all not excluded text
  4. Write! to file\n
    DELIMITER
  ARGF.each do |selection| 
    # increase scope to instance variable if needed!        
    @selection = selection.chomp!
    # only read one line                                                          
    break                       
  end
  case @selection
    when "1"                  
    @file_manager = FileManager.new
    current_file = @file_manager.send(:file_history_current)                                  
    when "2"
    ...
    else
      puts("Exiting")
      exit
  end
end

ARGF is your friend. It is not clear in the documentation but it works just like you would expect it to in 'C' (this is Ruby however). Remember that Ruby loves [] and you should be able to figure out most anything.

ARGF是你的朋友。它在文档中并不清楚,但它的工作方式与您在'C'中所期望的一样(但这是Ruby)。请记住,Ruby喜欢[],你应该能够弄清楚任何事情。

arguments = [arg1, arg2, arg3]
text_lines = @file_manager.send(:file_open, *arguments) 

def file_open(arg1, arg2, arg2)
  ...
end