博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Apple M1上如何用pip安装x86的Python Wheel包
阅读量:634 次
发布时间:2019-03-13

本文共 958 字,大约阅读时间需要 3 分钟。

最近可能很多人在犹豫要不要买Apple M1的苹果电脑,担心兼容性问题。其实完全不用担心。Apple M1绝对是强大的生产力工具。这里分享下如何用pip安装x86的Python wheel包。

安装pip

Mac自带Python 2.7。如果第一次在terminal中运行Python3,会提示安装。

在这里插入图片描述

点击安装之后。就可以运行Python3。

接下来安装pip:

curl https://bootstrap.pypa.io/get-pip.py -o get-pip.pypython3 get-pip.py

安装x86的wheel包

如果你直接用pip去安装包含x86库的Python包,会失败:

python3 -m pip install dbr

在这里插入图片描述

可能有人会觉得因为M1不兼容。这个时候来看下Python3的arch:

% file $(which python3)/usr/bin/python3: Mach-O universal binary with 2 architectures: [x86_64:Mach-O 64-bit executable x86_64] [arm64e:Mach-O 64-bit executable arm64e]/usr/bin/python3 (for architecture x86_64):	Mach-O 64-bit executable x86_64/usr/bin/python3 (for architecture arm64e):	Mach-O 64-bit executable arm64e

发现Python3是可以同时兼容arm64和x86的。苹果默认会当作arm64来执行。所以需要设置一下arch:

arch -x86_64 $(which python3) -m pip install dbr

另外,你也可以选择在vscode中直接运行调试Python程序,非常方便。

在这里插入图片描述

测试OpenCV打开摄像头

Mac对权限有限制,terminal无法运行程序打开摄像头。

安装iTerm2(https://iterm2.com)。在iTerm2中运行Python摄像头程序可以获得权限。

在这里插入图片描述

现在可以通过Python OpenCV接口打开摄像头了:

在这里插入图片描述

转载地址:http://pqlaz.baihongyu.com/

你可能感兴趣的文章