You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

为何conda defaults渠道安装的Python会错误识别macOS版本?

macOS Ventura下conda defaults渠道Python版本识别异常问题

在macOS Ventura(13.3)系统使用miniconda时,发现通过defaults渠道安装的Python调用platform.platform()返回的系统版本与系统原生Python、conda-forge渠道的Python不一致,且结果不正确,具体对比如下:

来源platform.platform() 返回值
defaults渠道安装的Python 3.11'macOS-10.16-x86_64-i386-64bit'
conda-forge渠道安装的Python 3.11'macOS-13.3.1-x86_64-i386-64bit'
xcode-select安装的原生Python 3.11'macOS-13.3.1-x86_64-i386-64bit'

排查发现的细节

进一步排查发现,defaults渠道创建的环境中,Python读取到的/System/Library/CoreServices/SystemVersion.plist内容和系统实际内容不符:

系统实际读取该文件的字符串内容:

[I] > cat /System/Library/CoreServices/SystemVersion.plist | grep string
    <string>6B08394E-D0A4-11ED-8DAB-1CA630367858</string>
    <string>22E261</string>
    <string>1983-2023 Apple Inc.</string>
    <string>macOS</string>
    <string>13.3.1</string>
    <string>13.3.1</string>
    <string>16.4</string>

而defaults渠道下的Python读取该文件的结果:

Python 3.9.16 (main, Mar  8 2023, 04:29:44)
[Clang 14.0.6 ] :: Anaconda, Inc. on darwin
>>> import plistlib
>>> fn  = "/System/Library/CoreServices/SystemVersion.plist"
>>> with open(fn, "rb") as f:
...     pl = plistlib.load(f)
...
>>> pl
{'BuildID': '6B08394E-D0A4-11ED-8DAB-1CA630367858', 'ProductBuildVersion': '22E261',
'ProductCopyright': '1983-2023 Apple Inc.',
'ProductName': 'Mac OS X',
'ProductUserVisibleVersion': '10.16',
'ProductVersion': '10.16',
'iOSSupportVersion': '16.4'}

问题原因

该问题确实和defaults渠道的构建链直接相关:defaults渠道的Python是基于旧版macOS编译的。macOS为了实现向下兼容,会对这类基于旧版系统编译的程序虚拟覆盖SystemVersion.plist的内容,让程序读取到旧版系统版本号(这里是10.16),而非当前实际的系统版本13.3.1,最终导致platform.platform()返回错误结果。

内容的提问来源于stack exchange,提问作者pml

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.23 11:27:41