Python/pip进程在virtualenv(Apple M1芯片)中被杀死 [英] Python/pip process are killed in virtualenv (Apple M1 chip)

查看:189
本文介绍了Python/pip进程在virtualenv(Apple M1芯片)中被杀死的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在MacBook M1芯片virtualenv中执行pip或python时,该过程总是立即终止并显示以下消息:
[1] 29116杀死pip [1] 29141杀死python .

When I execute pip or python in MacBook M1 chip virtualenv, the process always terminates immediately with message:
[1] 29116 killed pip and [1] 29141 killed python.

在M1 MacBook原生环境中使用python和pip是完全可以的.但是,如果我想使用virtualenv隔离开发环境,则无法使用.

It is totally ok to use python and pip in M1 MacBook native environment. However, if I want to use virtualenv to isolate the development env, it doesn't work.

推荐答案

经过研究,我发现它与"x86_64"相关.以及臂64"建筑学.要解决该问题,您必须在x86_64模式下运行virtualenv python/pip.

After some research, I find out it is related with "x86_64" and "arm 64" architecture. To solve the problem, you have to run virtualenv python/pip in x86_64 mode.

步骤:

  1. 禁用SIP :以恢复模式重启MacBook.打开 Utilities>终端输入 csrutil disable .ref:禁用和启用系统完整性保护
  2. 以x86_64模式运行SHELL :在终端中输入 arch -x86_64 $ SHELL .
  3. 成功执行python/pip
  1. Disable SIP: reboot MacBook in Recover Mode. Open Utilities > Terminal enter csrutil disable. ref: Disabling and Enabling System Integrity Protection
  2. Run SHELL as x86_64 mode: enter arch -x86_64 $SHELL in Terminal.
  3. Execute python/pip successfully

在那之后,我再次启用SIP并每次都继续使用 arch -x86_64 $ SHELL .它将成功在virtualenv中执行python/pip.

After that, I enable SIP again and keep using arch -x86_64 $SHELL every time. It will execute python/pip in virtualenv succesfully.

为了节省时间,我在 .zshrc 中添加了别名:

To save my time, I add an alias in my .zshrc:

alias x86 =" arch -x86_64 $ SHELL"

alias x86="arch -x86_64 $SHELL"

现在,如果我需要在x86_64模式下执行某些过程,只需键入 x86 打开x86_64 shell.

Now if I need execute some process in x86_64 mode, I just type x86 to open the x86_64 shell.

注意:github上的MxJ24提供了此解决方案,并列出了一些适用于python/django/brew的有用脚本: https://gist.github.com/MxJ24/e1386c9012f533cfbedfed5114da3e60

Note: MxJ24 on github provides this solution and lists some useful scripts for python/django/brew: https://gist.github.com/MxJ24/e1386c9012f533cfbedfed5114da3e60

这篇关于Python/pip进程在virtualenv(Apple M1芯片)中被杀死的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆