Andre
Andre

Reputation: 1377

Process finished with exit code 139 (interrupted by signal 11: SIGSEGV)

I'm trying to execute a Python script, but I am getting the following error:

Process finished with exit code 139 (interrupted by signal 11: SIGSEGV)

I'm using python 3.5.2 on a Linux Mint 18.1 Serena OS

Can someone tell me why this happens, and how can I solve?

Upvotes: 89

Views: 251976

Answers (24)

Marek F
Marek F

Reputation: 1

Beware of beepy ... It turned out to be the cause of exit code 139 in my case.

Upvotes: -1

flomaster
flomaster

Reputation: 1812

Not directly related to the Python script in question, but may be useful for readers:

I've had this problem using requests library with cert parameter (client-side certificate) in multi-threaded fashion. I solved it by using httpx library instead for this specific request. (You can use httpx.post() or get(), etc. methods directly without creating a Client – and the API is almost the same.

Upvotes: 0

mahanth967
mahanth967

Reputation: 21

After reeboting the syste, its working fine, but its keep on coming wheb tensorflow is using

Upvotes: 0

11 : SIGSEGV - This signal is arises when a memory segement is illegally accessed.

There is a module name signal in python through which you can handle this kind of OS signals.

If you want to ignore this SIGSEGV signal, you can do this:

signal.signal(signal.SIGSEGV, signal.SIG_IGN)

However, ignoring the signal can cause some inappropriate behaviours to your code, so it is better to handle the SIGSEGV signal with your defined handler like this:

def SIGSEGV_signal_arises(signalNum, stack):
    print(f"{signalNum} : SIGSEGV arises")
    # Your code

signal.signal(signal.SIGSEGV, SIGSEGV_signal_arises) 

Upvotes: 1

Doge Coin
Doge Coin

Reputation: 1

I Fixed the Process finished with exit code 139 (interrupted by signal 11: SIGSEGV) error

the problem is with import cv2. you need to use pip install numpy==1.24.3

this version of numpy fixed it. the newest version of numpy must be broken

Upvotes: 0

arneyjfs
arneyjfs

Reputation: 480

PYCHARM USERS

For a subset of people who find this problem, this might help. Turns out it can also be a PyCharm Debugger issue. Searching the internet for the issue and pycharm as a keyword turns up many results (maybe would too for other IDE debuggers).

Users suggested turning off PyQT compatibility in the debugger, amongst other things.

For me, weirdly this answer worked:

python/pycharm project produces segmentation fault in debug mode, but not in run mode (turning ON collecting runtime types in settings->build->python debugger)

Upvotes: 20

Daniel Olson
Daniel Olson

Reputation: 541

in my case it was a pickled file, specifically a pandas DataFrame. deleting the pickled file fixed the issue.

similar to this:

from pandas import DataFrame

df = DataFrame()

# somewhere
df.from_pickle('my_path.p')

# somewhere later
df.to_pickle('my_path.p')

Upvotes: 0

Marvin
Marvin

Reputation: 11

I got this error when importing monai. It was solved after I created a new conda environment. Possible reasons I could imagine were either that there were some conflict between different packages, or maybe that my environment name was the same as the package name I wanted to import (monai).

Upvotes: 0

user118967
user118967

Reputation: 5772

In my case, reverting my most recent conda installs fixed the situation.

Upvotes: 0

Balázs Herczeg
Balázs Herczeg

Reputation: 129

I got this error in PHP, while running PHPUnit. The reason was a circular dependency.

Upvotes: 2

Dimitris Paraschakis
Dimitris Paraschakis

Reputation: 651

This issue is often caused by incompatible libraries in your environment. In my case, it was the pyspark library.

Upvotes: 0

MichaelU
MichaelU

Reputation: 83

I had the same issue working with kmeans from scikit-learn. Upgrading from scikit-learn 1.0 to 1.0.2 solved it for me.

Upvotes: 0

Pablo Rees
Pablo Rees

Reputation: 11

This can also occur if trying to compound threads using concurrent.futures. For example, calling .map inside another .map call.

This can be solved by removing one of the .map calls.

Upvotes: 0

Khashayar
Khashayar

Reputation: 468

For me these three lines of code already reproduced the error, no matter how much free memory was available:

import numpy as np
from sklearn.cluster import KMeans

X = np.array([[1, 2], [1, 4], [1, 0], [10, 2], [10, 4], [10, 0]])
kmeans = KMeans(n_clusters=1, random_state=0).fit(X)

I could solve the issue by removing an reinstalling the scikit-learn package. A very similar solution to this.

Upvotes: 0

amir
amir

Reputation: 26

I encountered this problem when I was trying to run my code on an external GPU which was disconnected. I set os.environ['PYOPENCL_CTX']=2 where GPU 2 was not connected. So I just needed to change the code to os.environ['PYOPENCL_CTX'] = 1.

Upvotes: 0

Younes Belouche
Younes Belouche

Reputation: 1520

For me, I was using the OpenCV library to apply SIFT. In my code, I replaced cv2.SIFT() to cv2.SIFT_create() and the problem is gone.

Upvotes: 4

Rafa
Rafa

Reputation: 31

Deleted the python interpreter and the 'venv' folder solve my error.

Upvotes: 2

lux7
lux7

Reputation: 2160

I received the same error when trying to connect to an Oracle DB using the pyodbc module:

connection = pyodbc.connect()

The error occurred on the following occasions:

  • The DB connection has been opened multiple times in the same python file
  • While in debug mode a breakpoint has been reached while the connection to the DB being open

The error message could be avoided with the following approaches:

  • Open the DB only once and reuse the connection at all needed places
  • Properly close the DB connection after using it

Hope, that will help anyone!

Upvotes: 1

gies0r
gies0r

Reputation: 5239

This can also be the case if your C-program (e.g. using cpython is trying to access a variable out-of-bound


ctypedef struct ReturnRows:
    double[10] your_value

cdef ReturnRows s_ReturnRows # Allocate memory for the struct
s_ReturnRows.your_value = [0] * 12

will fail with

Process finished with exit code 139 (interrupted by signal 11: SIGSEGV)

Upvotes: 6

Ashish
Ashish

Reputation: 21

found on other page. interpreter: python 3.8

cv2.CascadeClassifier(cv2.data.haarcascades + "haarcascade_frontalface_default.xml")

this solved issue for me. i was getting SIGSEGV with 2.7, upgraded my python to 3.8 then got different error with OpenCV. and found answer on OpenCV 4.0.0 SystemError: <class 'cv2.CascadeClassifier'> returned a result with an error set.

but eventually one line of code fixed it.

Upvotes: -1

Josh Friedlander
Josh Friedlander

Reputation: 11657

Another possible cause (which I encountered today) is that you're trying to read/write a file which is open. In this case, simply closing the file and rerunning the script solved the issue.

Upvotes: 23

Andre
Andre

Reputation: 1377

After some times I discovered that I was running a new TensorFlow version that gives error on older computers. I solved the problem downgrading the TensorFlow version to 1.4

Upvotes: 12

madogan
madogan

Reputation: 665

When I encounter this problem, I realize there are some memory issues. I rebooted PC and solved it.

Upvotes: 6

Jean-Paul Calderone
Jean-Paul Calderone

Reputation: 48335

The SIGSEGV signal indicates a "segmentation violation" or a "segfault". More or less, this equates to a read or write of a memory address that's not mapped in the process.

This indicates a bug in your program. In a Python program, this is either a bug in the interpreter or in an extension module being used (and the latter is the most common cause).

To fix the problem, you have several options. One option is to produce a minimal, self-contained, complete example which replicates the problem and then submit it as a bug report to the maintainers of the extension module it uses.

Another option is to try to track down the cause yourself. gdb is a valuable tool in such an endeavor, as is a debug build of Python and all of the extension modules in use.

After you have gdb installed, you can use it to run your Python program:

gdb --args python <more args if you want>

And then use gdb commands to track down the problem. If you use run then your program will run until it would have crashed and you will have a chance to inspect the state using other gdb commands.

Upvotes: 77

Related Questions