gpt4 book ai didi

zsh: killed python3 on M1 MacBook Pro(Zsh:在M1 MacBook Pro上杀死了python3)

转载 作者:bug小助手 更新时间:2023-10-26 20:16:49 26 4
gpt4 key购买 nike



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:

我正试着在新的M1芯片MacBook上运行Python3。我尝试通过官方网站(https://www.python.org/downloads/release/python-391/)和BREW安装python3来安装python3。这两个安装都成功了,但是当我尝试在终端中运行命令python3时,我得到了这个错误:


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?

有人知道这是怎么回事吗?我在网上找不到任何东西,我想我的安装应该是正常的。我确实必须为一个类更改~/.zshc文件,但我不确定这是否是问题所在?


更多回答

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.

你查过窃听器追踪系统了吗?“为一个类更改我的~/.zshrc文件”--如果您想知道这是否是问题所在,有一个非常简单的方法可以找到答案,只需恢复更改。

@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.

@JunlinYi:我希望您没有在不知道自己在做什么的情况下盲目地更改您的.zshc,但如果您怀疑这可能是原因,请尝试通过zsh--fc python3运行Python,或者从bash登录外壳运行;它仍然会被杀死吗?此外,还要调查文件$(where-c python3)输出的内容。

优秀答案推荐

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

我在M1 Macbook Pro中遇到了同样的问题,并通过执行以下操作修复了该问题


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

打开~/.zshc文件(如果还不存在,则创建一个新文件)添加以下行


alias python3="/usr/bin/python3"

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

通过运行以下命令,确保您能够从上面的位置访问python3


/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.

这应该会为您调用Python3,或者检查/usr/bin中的正确路径,并相应地更新上面的行。您也可以相应地对其他版本的Python执行相同的操作。



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).

对于其他可能有相同根本原因的人:我的与我的Python安装无关,它是由Pandas中的错误合并引起的(意外创建了一个具有220亿行的框架,它试图分配33GB的内存)。



Try reinstalling python and all dependencies using homebrew!

尝试使用自制软件重新安装PYTHON和所有依赖项!


brew reinstall $(brew deps python3) python3


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.

我怀疑是内姆泄露的,但我不能肯定。然后,我会尝试重新安装Python,但最终没有必要这样做。



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.

我自己也开始面临同样的问题,当时我使用的是M1芯片的MacBook和MacOS蒙特雷。我正在使用VS代码来尝试运行我的Python脚本,它运行得很好。但当我在终端上尝试时,我一直收到同样的回应。


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

我找到的有效的简单解决方案是指定我正在运行的是哪一个Python版本。例如:假设我有一个名为Testing.py的文件,并且我运行的是最新版本的python3.x,那么在我的终端上我会这样做


python3.X testing.py

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

一切似乎都很好(至少对我来说)。


Enjoy

享受



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

在我的例子中,Python数据分析包试图突破PC内存限制。减少计算矩阵后,程序运行正常!



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

我也犯了同样的错误。然后我禁用了MacOS系统完整性保护(SIP),python3运行正常。


更多回答

What is the actual issue, and why does this fix it?

实际问题是什么?为什么这样可以解决它?

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com