PyCharm: Process finished with exit code 0

前端 未结 9 1907
感情败类
感情败类 2021-02-13 16:51

I am new to PyCharm and I have \'Process finished with exit code 0\' instead of getting (683, 11) as a result (please see attachment), could you guys help me out please? Much ap

相关标签:
9条回答
  • 2021-02-13 17:22

    please add your code and not the attachment. Also, this means that the compilation was successful (no errors). Pycharm and command prompt (Windows OS), terminal (Ubuntu) don't work the same way. Pycharm is an editor and if you want to print something, you explicitly have to write the print statement:

    print(whatever_you_want_to_print)
    

    In your case,

    print(data.shape)
    

    Hope it helps.

    0 讨论(0)
  • 2021-02-13 17:25

    That is good news! It means that there is no error with your code. You have run it right through and there is nothing wrong with it. Pycharm returns 0 when it has found no errors (plus any output you give it) and returns 1 as well as an error message when it encounters errors.

    Editors and scripts do not behave like the interactive terminal, when you run a function it does not automatically show the the result. You need to actually tell it to do it yourself.

    Generally you just print the results.

    If you use print(data.shape) it should return what you expect with the success message Process finished with exit code 0.

    0 讨论(0)
  • 2021-02-13 17:26

    exit code 0 means you code run with no error.

    Let's give a error code for example(clearly in the below image): in below code, the variable lst is an empty list, but we get the 5 member in it(which not exists), so the program throws IndexError, and exit 1 which means there is error with the code.

    You can also define exit code for analysis, for example:

    ERROR_USERNAME, ERROR_PASSWORD, RIGHT_CODE = 683, 11, 0
    right_name, right_password = 'xy', 'xy'
    
    name, password = 'xy', 'wrong_password'
    
    if name != right_name:
        exit(ERROR_USERNAME)
    
    if password != right_password:
        exit(ERROR_PASSWORD)
    
    exit(RIGHT_CODE)
    

    0 讨论(0)
  • 2021-02-13 17:31

    I had same problem with yours. And I finally solve it I see you are trying to run code "Kaggle - BreastCancer.py" but your pycharm try to run "Breast.py" instead of your code. (I think Breast.py only contains functions so pycharm can run without showing any result) Check on tab [Run] which code you are trying to run.

    0 讨论(0)
  • 2021-02-13 17:33

    I just ran into this, but couldn't even run a simple print('hello world') function.

    Turns out Comodo's Firewall was stopping the script from printing. This is a pretty easy fix by deleting Python out of the Settings > Advanced > Script Analysis portion of Comodo.

    Good Luck

    0 讨论(0)
  • 2021-02-13 17:36

    I would recommend you to read up onexit codes.

    exit 0 means no error.

    exit 1 means there is some error in your code.

    This is not pyCharm or python specific. This is a very common practice in most of the programming languages. Where exit 0 means the successful execution of the program and a non zero exit code indicates an error.

    0 讨论(0)
提交回复
热议问题