最近很好高兴用上了新版的macbook(芯片:Apple M3 Pro,操作系统:14.3)。
不高兴的是遇到了不兼容的问题。所以选型还是成熟的技术是关键。
电脑里用pyenv 工具管理多个版本的python。 命令:pyenv install xxx
pyenv install 3.6.0
python-build: use openssl from homebrew
python-build: use readline from homebrew
Installing Python-3.6.0...
python-build: use readline from homebrew
python-build: use zlib from xcode sdk
BUILD FAILED (OS X 14.3 using python-build 20180424)
Inspect or clean up the working tree at /var/folders/qc/614hn1lj1yq534r0pvk0m3p40000gp/T/python-build.20240712100929.1951
Results logged to /var/folders/qc/614hn1lj1yq534r0pvk0m3p40000gp/T/python-build.20240712100929.1951.log
Last 10 log lines:
checking for long double support... yes
checking size of long double... 8
checking size of _Bool... 1
checking size of off_t... 8
checking whether to enable large file support... no
checking size of time_t... 8
checking for pthread_t... yes
checking size of pthread_t... 8
configure: error: Unexpected output of 'arch' on OSX
make: *** No targets specified and no makefile found. Stop.
想要安装个3.6的版本是不行了,最后试试到3.12.2 版本可以成功安装。最新的python开始兼容M3芯片了。
想要安装更低版本的python,可以参考下面的命令: arch -x86_64 pyenv install xxx
arch -x86_64 pyenv install 3.8.9
python-build: use openssl from homebrew
python-build: use readline from homebrew
Downloading Python-3.8.9.tar.xz...
-> https://www.python.org/ftp/python/3.8.9/Python-3.8.9.tar.xz
Installing Python-3.8.9...
patching file 'Misc/NEWS.d/next/Build/2021-10-11-16-27-38.bpo-45405.iSfdW5.rst'
patching file configure
patching file configure.ac
python-build: use readline from homebrew
python-build: use zlib from xcode sdk
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/Users/xxx/.pyenv/versions/3.8.9/lib/python3.8/lzma.py", line 27, in <module>
from _lzma import *
ModuleNotFoundError: No module named '_lzma'
WARNING: The Python lzma extension was not compiled. Missing the lzma lib?
Installed Python-3.8.9 to /Users/xxx/.pyenv/versions/3.8.9
用这种方法可以安装3.8.9及以上,但安装过程有报错,也算是安装上了。
还有一种办法,去python的官网下载安装包,手动安装,但这种办法不符合pyenv的管理。
总结:版本兼容的问题。