Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PyCharm: Process finished with exit code 0

Tags:

python

pycharm

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 appreciate it!

enter image description here

like image 363
ET44 Avatar asked Mar 24 '18 01:03

ET44


People also ask

What is process exit code 0?

Process - Exit (Code|Status) The exit code or exit status is a number returned by a process created by a command line indicating if there was an error or not. 0 means that there is no error. an other value means that there was an error.

Why is my Pycharm code not running?

Make sure the file that you want to run is on top. Hit ctrl+shift+F10 to run. The run button should be enabled again.

What does process finished with exit code 1 mean in Pycharm?

Exit Code 1 means that a container terminated, typically due to an application error or an invalid reference. An application error is a programming error in any code running within the container.

What does exit 0 do in python?

The function calls exit(0) and exit(1) are used to reveal the status of the termination of a Python program. The call exit(0) indicates successful execution of a program whereas exit(1) indicates some issue/error occurred while executing a program.


2 Answers

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.

like image 128
Xantium Avatar answered Sep 17 '22 17:09

Xantium


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.

enter image description here

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)

enter image description here

like image 31
Jayhello Avatar answered Sep 21 '22 17:09

Jayhello