Process finished with exit code 137 in PyCharm

PythonPycharmXgboost

Python Problem Overview


When I stop the script manually in PyCharm, process finished with exit code 137. But I didn't stop the script. Still got the exit code 137. What's the problem?

Python version is 3.6, process finished when running xgboost.train() method.

Python Solutions


Solution 1 - Python

Exit code 137 means that your process was killed by (signal 9) SIGKILL . In the case you manually stopped it - there's your answer.

If you didn't manually stop the script and still got this error code, then the script was killed by your OS. In most of the cases, it is caused by excessive memory usage.

Solution 2 - Python

{In my experience}

this is because of Memory issue. When I try to train ml model using sklearn fit with full data set , it abruptly breaks and gives whereas with small data it works fine.

Process finished with exit code 137 (interrupted by signal 9: SIGKILL) Interestingly this is not caught in Exception block either

Solution 3 - Python

If you are in Ubuntu, increase the SWAP memory. It will work. Use htop to see SWAP usage, when it is full, it will give error 137.

Solution 4 - Python

I had the same error. In my case was related to excessive memory usage. Solved after reseting/cleaning my cache data adding the following code for every variable that will not be used anymore :

MyVariableName = None

Solution 5 - Python

It's not always a memory issue. In my case subprocess.Popen was utilized and it was throwing the error as 137 which looks like signalKILL and the cause is definitely not the memory utilization, because during the runtime it was hardly using 1% of memory use. This seems to be a permission issue after more investigation. I simply moved the scripts from /home/ubuntu to the root directory.

Solution 6 - Python

I've recently run into this error installing PyCharm on an M1 Mac Mini. It was accompanied by an error that said my SDK was invalid upon compilation of a project. It turns out this was due to my Python Interpreter being pointed at a strange directory, I'm not 100% how this happened.

I went to Preferences > Project:yourProject > Python Interpreter and selected a valid SDK from the drop-down (in my case Python 3.8). You'll know the package is valid because it will populate the package list below with packages.

Again, not sure how it happened on install, but this solved it.

Solution 7 - Python

In my case, my RAM ran out, whether it is real or virtual.

Split your data into small pieces or expand your virtual memory.

I choose the latter.

Following scipts works on my ubuntu 20.04 TLS.

# disable the use of swap
sudo swapoff -a

# create the SWAP file. Make sure you have enough space on the hard disk.
# here is my size, the total size is bs*count B
sudo dd if=/dev/zero of=/swapfile bs=1024 count=136314880 status=progress
# output:
# 139458259968 bytes (139 GB, 130 GiB) copied, 472 s, 295 MB/s
# 136314880+0 records in
# 136314880+0 records out
# 139586437120 bytes (140 GB, 130 GiB) copied, 472.372 s, 296 MB/s

# Mark the file as SWAP space:
sudo mkswap /swapfile
# output:
# Setting up swapspace version 1, size = 130 GiB (139586433024 bytes)
# no label, UUID=25a565d9-d19c-4913-87a5-f02750ab625d

# enable the SWAP.
sudo swapon /swapfile

# check if SWAP is created
sudo swapon --show
# output:
# NAME      TYPE SIZE USED PRIO
# /swapfile file 130G   0B   -2

# Once everything is set, you must set the SWAP file as permanent, else you will lose the SWAP after reboot. Run this command:
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab

After you run your process, memory will grow.

Here is mine:

enter image description here

Good Luck!

reference 1reference 2

Solution 8 - Python

My python process get killed with the 137 error code because my Docker for Windows memory limit was set too low.

Solution 9 - Python

  1. If anyone else were installing pycharm on mac and got the code 137 in PyCharm error while doing a simple print('test') command it most certainly is because of the path to interpreter being present in the new project created.
  2. The error I believe is because of python being installed through brew and it not showing up in the "Python X.YZ /Library/Frameworks/Python.framework/Versions/X.YZ/bin/pythonX" path
  3. Work around uninstall installed python version using brew and then manually install it.
  4. Now it would appear under the interpreter path which is under "Preferences-> Project -> Python Interpreter -> Gear symbol -> add base interpreter" point this to under /Library/Frameworks/.... path

Solution 10 - Python

  1. Click on the gear icon.
  2. Then set the Poetry environment to Python 3.x.
  3. Click Ok and Apply.

Now the code can run without showing any error!

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionshaweView Question on Stackoverflow
Solution 1 - PythonykanerView Answer on Stackoverflow
Solution 2 - PythonBrBView Answer on Stackoverflow
Solution 3 - PythonASJView Answer on Stackoverflow
Solution 4 - PythonCamiloView Answer on Stackoverflow
Solution 5 - Pythonuser11009049View Answer on Stackoverflow
Solution 6 - PythoncodeasaurusRektView Answer on Stackoverflow
Solution 7 - PythonHuaiyu HuangView Answer on Stackoverflow
Solution 8 - PythonAlex HorvathView Answer on Stackoverflow
Solution 9 - PythonrvaView Answer on Stackoverflow
Solution 10 - PythonSumit SumanView Answer on Stackoverflow