zsh: killed python3 on M1 MacBook Pro
Asked Answered
A

7

14

I'm trying to run Python 3 on the new M1 chip MacBook. I tried installing python3 both via the official Python website (https://www.python.org/downloads/release/python-391/) and also via brew install python3. Both of the installations succeeded, however when I try running the command python3 in Terminal I get this error:

zsh: killed     python3

Does anyone know what's going on? I couldn't find anything online and I think my installation should be fine. I did have to change my ~/.zshrc file for a class, but I'm not sure if that's the issue?

Ardell answered 20/2, 2021 at 18:30 Comment(2)
Have you checked the bugtracking system? "change my ~/.zshrc file for a class" -- if you're wondering whether that's the issue, there's a very simple way to find out, just revert the changes.Ferricyanide
@JunlinYi : I hope that you did not blindly change your .zshrc without knowing what you are doing, but if you suspect that this could be the reason, try to run Python via zsh --fc python3, or from a bash login shell; is it still killed? Also, investigate what file $(whence -c python3) outputs.Warram
A
12

For others who might have the same root cause: Mine had nothing to do with my Python installation, it was caused by a bad merge in Pandas (accidently creating a dataframe with 22 Billion rows, it was trying to allocate 33GB of memory).

Acquisitive answered 31/5, 2023 at 15:28 Comment(0)
T
11

I faced this same issue in the M1 Macbook pro and fixed it by doing the following

Open ~/.zshrc file (Create a new one if not present already) Add the following line

alias python3="/usr/bin/python3"

Make sure you are able to access python3 from the above location by running

/usr/bin/python3

This should invoke Python3 for you or check for the correct path in /usr/bin and update the above line accordingly. You can do the same for other versions of Python also accordingly.

Taliped answered 20/7, 2021 at 11:52 Comment(1)
What is the actual issue, and why does this fix it?Hoarding
C
2

I ran into this issue and it was resolved by an ol' fashioned computer restart!

I suspect a mem leak but I'm not sure. I would have then tried reinstalling Python but it ended up not being necessary.

Colonic answered 18/8, 2023 at 20:57 Comment(0)
A
1

Try reinstalling python and all dependencies using homebrew!

brew reinstall $(brew deps python3) python3
Ahoufe answered 29/4, 2021 at 11:41 Comment(0)
M
0

I started to face the same issue myself while on M1 chip MacBook with macOS Monterey. I was using VS code to try to run my python script and it worked fine. But when I tried it on the terminal I kept getting that same response.

The simple solution that I found to work was specifying which python version I was running. Ex: say I have a file named testing.py and I am running the latest version of python 3.X, then in my terminal I would do

python3.X testing.py

and everything seemed to run just fine (at least for me).

Enjoy

Montenegro answered 25/8, 2022 at 16:46 Comment(0)
J
0

In my case, the Python data analysis package attempted to cross pc memory limit. After I decrease the computational matrix the program run ok!

Joggle answered 10/4, 2023 at 17:5 Comment(0)
F
-2

I got a same error. Then I disabled MacOS System Integrity Protection(SIP), python3 runs correctly.

Flunk answered 29/3, 2021 at 11:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.