V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
shinsekai
V2EX  ›  Python

如何在 arm Mac 上安装 x86 版 python3.10

  •  
  •   shinsekai · 18 天前 · 1417 次点击

    有一个 x86 软件需要指定 python 3.10 的位置,现在尝试了几种方法都没有解决:

    1. 官方二进制包,3.9 版本提供 intel 版单独 pkg ,3.10 开始只有 universal 安装包,安装后默认 arm

    2. 使用 Homebrew ,由于使用 arm64 homebrew ,前缀 arch x86 安装软件时会提示 Cannot install under Rosetta 2 in ARM default prefix ,需要将 homebrew 安装到/usr/local ,而不是/opt

    3. 使用 pyenv ,前缀 arch x86 安装时提示 BUILD FAILED ,提示 subprocess.CalledProcessError: Command ......died with <Signals.SIGABRT: 6>.,而 build arm 版 python 则正常。

    请问还有什么装 python 的办法吗

    16 条回复    2024-04-26 10:51:59 +08:00
    yulgang
        1
    yulgang  
       18 天前
    装个 x86 的虚拟机
    elechi
        2
    elechi  
       18 天前
    从别人 x86 电脑上拷贝过来
    dingdangnao
        3
    dingdangnao  
       18 天前
    开个服务器吧
    EastLord
        4
    EastLord  
       18 天前
    无解,如果开发要用,可以装个 arm linux 虚拟机,然后用 arm 版本的 python3.10
    Davic1
        5
    Davic1  
       18 天前
    https://github.com/jdx/mise

    可以试试这个,指定版本
    baobao1270
        6
    baobao1270  
       18 天前
    Python 应该是架构无关的吧,我猜 x86 软件应该可以调用 aarch 的 Python ,毕竟一般提供外部路径都是走 Pipe / Command Line 的。
    Pyenv build failed ,可能是缺依赖,说不定是系统自带 aarch 的依赖没带 x86 的
    Ricardoo
        7
    Ricardoo  
       18 天前
    用 conda , 我试了下,可以安装 x86 版本 python
    conda create -n my_x86_env -y
    conda activate my_x86_env
    conda config --env --set subdir osx-64
    conda install python=3.10
    file $(which python)
    /opt/miniconda3/envs/my_x86_env/bin/python: Mach-O 64-bit executable x86_64
    livenux
        8
    livenux  
       18 天前
    @Ricardoo https://www.pypy.org/download.html pypy 也有 x86 的版本下载,我一般有不兼容 arm 的包都是用 pypy 版的 python
    zhangchioulin
        9
    zhangchioulin  
       18 天前
    使用 lipo 强制分割出 x86 版本然后自己签名一下?
    atpex
        10
    atpex  
       18 天前
    买一台插 86 的 mac
    darcyC
        11
    darcyC  
       17 天前
    用 arch 指令可以指定运行架构,这边给几个例子
    arch -arch x86_64 XXXXX
    arch -arch x86_64 python
    arch -arch x86_64 python -m pip XXXXX
    arch -arch x86_64 XXXXXX/bin/pyinstaller XXXXX
    我自己用这个在 arm 架构系统上打包 intel 架构的可执行文件,你具体测试的时候可以在脚本里用下面的代码看当前的架构
    arch = platform.machine()
    具体的话你可以 man arch 看怎么用
    darcyC
        12
    darcyC  
       17 天前
    我补充一下上面的内容,为了让所有的流程都可以用,所有的指令前面都要加 arch -arch x86_64 ,包括 pip 等,因为 pip 也会根据当前架构选择下载何种执行文件。arch 指令本质上就是在 universal 包里选择某一种的架构去运行。
    CHEN1016
        13
    CHEN1016  
       17 天前 via iPhone
    rosetta2 x86 虚拟机
    huangzhe8263
        14
    huangzhe8263  
       17 天前
    如果有 docker 的话可以试试按 x86 的镜像然后安 python
    shinsekai
        15
    shinsekai  
    OP
       17 天前
    @darcyC 使用 arch x86_64 安装 homebrew 后再装 python 可以了,暂时没发现双版本 homebrew 共存有什么问题。
    craiiz
        16
    craiiz  
       17 天前
    记得终端可以切换到 x86 模式,忘记怎么搞了,你查一下
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   5667 人在线   最高记录 6547   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 23ms · UTC 08:06 · PVG 16:06 · LAX 01:06 · JFK 04:06
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.