我一直在尝试使用 Yosemite 和全新安装的 ActiveState Python 3.4 在 MacBook Pro 上安装 numpy、pysci 等。我已经尝试了很多轮文件,但它们都失败了“此平台上不支持轮”。例如,使用来自 https://pypi.python.org/pypi/numpy 的 Python 3.4 的最新轮文件:
...$ sudo pip3 install numpy-1.9.1-cp34-cp34m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl
numpy-1.9.1-cp34-cp34m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl is not a supported wheel on this platform.
我通过 wheel.py、req.py 和 pep425tags.py 跟踪我的方式,试图了解它失败的原因。
在 pep425tags.py 中它使用
distutils.util.get_platform().replace('.', '_').replace('-', '_')
大概,然后将其与轮文件的文件名中的标签进行比较。
由于我已升级到优胜美地,我希望我的计算机会返回类似:“macosx_10_10_intel”或“macosx_10_10_x86_64” - 但它返回“macosx_10_6_x86_64”
>>> import distutils.util
>>> distutils.util.get_platform().replace('.', '_').replace('-', '_')
'macosx_10_6_x86_64'
>>>
优胜美地显然在报告它是雪豹,我是否正确?还是 Python 3.4 弄错了?这是我的车轮文件问题吗?如果是这样,是否有解决办法?
更新到 Python 3.4.2 解决了这个问题,我能够安装 numpy wheel 文件。
但是请注意,distutils.util.get_platform() 仍然报告“macosx_10_6_intel”,但这并不影响安装。
Python 3.4.2 (v3.4.2:ab2c023a9432, Oct 5 2014, 20:42:22)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "copyright", "credits" or "license()" for more information.
>>> import distutils.util
>>> distutils.util.get_platform().replace('.', '_').replace('-', '_')
'macosx_10_6_intel'
最佳答案
考虑到distutils.util.get_platform()
返回运行二进制文件的最小版本:
For Mac OS X systems the OS version reflects the minimal version on which binaries will run (that is, the value of
MACOSX_DEPLOYMENT_TARGET
during the build of Python), not the OS version of the current system.
强调我的。也就是说,对于 Python 3.4,如果您在该平台上构建 Python,您可以合理地期望值是 10.10。
用于 Python 处理
MACOSX_DEPLOYMENT_TARGET
要在整个过程中正常工作,您需要升级到 Python 3.4.2; 3.4.1 不适用于 Mac OS X 10.10 或更高版本。见问题 #21811 :There are a number of places within the cpython code base where decisions are made based on either the running system version or the OS X ABI (e.g. the value of MACOSX_DEPLOYMENT_TARGET) that the interpreter was built with or is being built with. Most of the current tests do string comparisons of these values which will not work properly with a two-digit version number ('10.10' < '10.9' --> True).
3.4.2 包括所需的修复。这同样适用于 Python 2.7 至 2.7.7 版本;如果您在 Python 2.7 升级到 2.7.8 或更高版本中看到同样的问题。
如果没有修复,
intel
与 x86_64
混为一谈,就像您的设置一样:
- When running current 3.4.1 and 2.7.7 binary installers on 10.10, building C extension modules will likely result in an incorrect universal platform name, for example, "x86_64" instead of "intel", and that could affect extension module file names and wheel or egg names.
作为引用,在我的 OS X 10.10 系统上,在 Python 3.4.2 上
get_platform()
的结果是:>>> import distutils.util
>>> distutils.util.get_platform()
'macosx-10.10-x86_64'
对于 Python 2.7.8,我得到:
>>> import distutils.util
>>> distutils.util.get_platform()
'macosx-10.4-x86_64'
关于python-3.x - Python 3.4 pip install wheel 在 Yosemite 上失败 - "not a supported wheel on this platform",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27203967/