Skip to content Skip to sidebar Skip to footer

'python' Command Segmentation Fault On Raspberry Pi

My problem is fairly simple: running the 'python' command (not a script) on my raspberry pi model A+ running Raspbian Wheezy gives a segmentation fault: pi@raspberrypi ~ $ python S

Solution 1:

The messages you’re getting from GDB when running Python suggest the Python executable you’re trying to use is for some reason corrupted. Try reinstalling all Python-related packages:

$ sudo apt-get install --reinstall `dpkg --get-selections | grep -E '^(lib)?python' | cut -f1 | cut -d: -f1`

Solution 2:

I had a similar problem where python3 was segfaulting, but apt could not install or remove packages because it invokes /usr/bin/apt-listchanges, a Python 3 script that couldn't execute.

At one point I received the message cannot open /var/lib/dpkg/info/parted.list (Structure needs cleaning) which suggested that there was some filesystem corruption. So if you encounter this issue, see if this is the case.

I created the /forcefsck file to force a filesystem repair on the next boot. The system didn't come back up—better have a serial cable and a spare SD card ready.

If it had come back up, I would have run apt install python3-dbg to download the GDB debugging extensions, even if apt would eventually crash — you could install manually with sudo dpkg -i /var/cache/apt/archives/python3.7-dbg*.deb.

Solution 3:

I had a similar problem on a Raspberry Pi, in my case with Python2. Like @rgov and @icktoofay suggest I had a corrupted binary. gdb wouldn't even load the binary. After a forced fsck, sudo dpkg -i /var/cache/apt/python2.7* fixed this problem, and I was then able to do a sudo apt --fix-broken install. It's possible that my card is failing, or that low power quality is causing write failures.

Post a Comment for "'python' Command Segmentation Fault On Raspberry Pi"