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.

Answer from Manu mathew on Stack Overflow
🌐
Reddit
reddit.com › r/linuxquestions › zsh killing my python script
r/linuxquestions on Reddit: zsh killing my python script
April 21, 2020 -

When I run my python program in zsh using python3 Mosesh.py I get the message zsh: killed python3 Mosesh.py after a few seconds. All the program is doing at the moment is creating a list of data to work with but at most that should be about 14kB so being out of ram doesn’t seem to be the issue as most of my googling has suggested. I’ve also noticed the issue persists in other shells such as bash. Any ideas what the issue is or how to fix it? Thanks.

🌐
Apple Community
discussions.apple.com › thread › 254356633
zsh: killed ---> new mac need help - Apple Community
November 7, 2022 - Log out and back in, and try python3 again. This if the installer added something in a zsh login script.
🌐
Stack Overflow
stackoverflow.com › questions › 72085413 › zsh-killed-python3-model-py
python - zsh: killed python3 model.py - Stack Overflow
zsh: no such file or directory: #!/usr/bin/env python3 · 2 · zsh: command not found: import · 1 · zsh & python. trying to use python script in zsh prompt, however, cannot · 0 · zsh: commands not working for pip, conda, python · 2 · zsh: abort python error when I try to run the app in venv · 17 · zsh: killed python3 on M1 MacBook Pro ·
🌐
Reddit
reddit.com › r/linuxquestions › zsh: killed python3 model.py
r/linuxquestions on Reddit: zsh: killed python3 model.py
May 2, 2022 -

dmesg printed 'Unable to obtain kernel buffer: Operation not permitted'.

Trying to run a k-NN model on unseen data and getting this error, code runs fine with a smaller sample just when it came to the entire dataset it got this error.

🌐
GitHub
github.com › pypa › pipenv › issues › 4502
'zsh: killed python' while executing from virtualenv on macOS Big Sur for Python 2.7 · Issue #4502 · pypa/pipenv
October 27, 2020 - zsh: killed python while executing from virtualenv on macOS Big Sur (platform: arm64) for Python 2.7 It is working fine for Python 3.8 Expected result Python Shell should launch from virtual env sh...
Author   pypa
🌐
Stack Overflow
stackoverflow.com › questions › 72638379 › zsh-killed-python3-on-m1-pro-macbook-pro
python - zsh: killed python3 on M1 Pro MacBook Pro - Stack Overflow
hello I've ran into a problem with running python3 on M1 MacBook pro. I deleted a version of python, after that I checked what version I was running and I get "zsh: killed python3". p...
🌐
YouTube
youtube.com › watch
zsh killed python3 on M1 MacBook Pro
Enjoy the videos and music you love, upload original content, and share it all with friends, family, and the world on YouTube.
Find elsewhere
🌐
GitHub
github.com › pypa › pipenv › issues › 4715
zsh killed python · Issue #4715 · pypa/pipenv
June 7, 2021 - I downgraded the python3 version on my macOS and tried both ways of installing the python. One through the terminal and another of manual installation. After that, when I check the python3 version it says "zsh : killed python3 --version"...
Author   pypa
🌐
Image.sc
forum.image.sc › usage & issues
Update ZSH killed during training - Usage & Issues - Image.sc Forum
September 28, 2023 - I posted here a little while ago regarding the ZSH killed issue I’ve been experiencing. I tried erasing the program, environment, really everything associated with DLC and trying again. I’m still running into some issues, at about iteration ~3500 the program returns: zsh: killed python -m deeplabcut I’m provided with this traceback when restarting as well: Traceback (most recent call last): File "/Users/jakeziegler/Desktop/deeplabcut/DeepLabCut/deeplabcut/gui/tabs/train_network.py", lin...
🌐
Glarity
askai.glarity.app › search › Why-does-my-Python-script-get-killed-when-running-in-zsh-on-my-Mac
Why does my Python script get killed when running in zsh on my Mac? - Ask and Answer - Glarity
When you encounter the message `zsh: killed python3` while running a Python script in zsh on your Mac, it typically indicates that the operating system has terminated the Python process.
🌐
Image.sc
forum.image.sc › usage & issues
ZSH killed during training - Usage & Issues - Image.sc Forum
September 12, 2023 - Every time I try training, my console returns zsh: killed python -m deeplabcut What can I do to fix this? Should I just uninstall and reinstall?
🌐
GitHub
github.com › microsoft › vscode › issues › 192460
zsh: killed · Issue #192460 · microsoft/vscode
September 7, 2023 - Type: Bug I have this problem in my terminal on my Mac and in the terminal on Visual studio Code. When I type python3 and python3 -version it gives me zsh: killed. Im new to coding and it didnt do ...
Author   microsoft
🌐
Statalist
statalist.org › forums › forum › general-stata-discussion › general › 1650118-pystata-does-not-work-in-mac-m1
pystata does not work in Mac M1 - Statalist
Python 3.8.9 (default, Jul 19 2021, 09:37:30) [Clang 13.0.0 (clang-1300.0.27.3)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import stata_setup >>> stata_setup.config('/Applications/Stata', 'mp') [0.003s][warning][os,thread] Attempt to protect stack guard pages failed (0x000000016b080000-0x000000016b08c000). zsh: killed python3
🌐
GitHub
github.com › jupyter › notebook › issues › 6007
Jupyter notebook gets killed by zsh on Apple M1 · Issue #6007 · jupyter/notebook
March 15, 2021 - Describe the bug When I run jupyter notebook zsh kills it on Apple M1. This is the native version of notebook. It does run correctly under Rosetta2 on the same machine. I had successfully installed and run it in natively on M1 with the earlier versions of the code / OS. I am using homebrew installed python3 ...
Author   jupyter
🌐
Apple Developer
developer.apple.com › forums › thread › 734345
Python script get killed only when… | Apple Developer Forums
It seems like the system is killing the process when it starts using a certain threshold of resources. I am on a brand new M2 MacBook Pro with 16gb of ram. I've tried restarting my computer and I've reinstalled python from several different sources, all to no avail. When it crashed, the shell says nothing more than "zsh: killed".
🌐
Apple Developer
developer.apple.com › forums › thread › 809830
Zsh kills Python process with plen… | Apple Developer Forums
December 11, 2025 - This folder has about 470 GB of ... about 40GB of virtual memory occupied (and thus still plenty of available space in VM), zsh kills the python process responsible for the RAM usage (notably, it does not kill another python process using only about 100 MB of RAM)...