1

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

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

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

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

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

(5) restarted my computer

(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

(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.

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.

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

Thanks in advance for your help.

D-Shih
  • 44,943
  • 6
  • 31
  • 51
ajwong4
  • 121
  • 2
  • 12

1 Answers1

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.

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.

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:

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.

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

def file_open(arg1, arg2, arg2)
  ...
end
  • heh, heh! no doubt I'm doing something wrong! i didn't figure it out for the program i was working on. the next program i wrote worked fine. i had created a new project which probably created a new launch script, so maybe that was the difference. go figure. thanks, richard! – ajwong4 Feb 13 '18 at 03:34